SlideShare uma empresa Scribd logo
1 de 34
Baixar para ler offline
alfresco.js / share.js
Hidden gems in Alfresco Client-Side Javascript
2013-06-27 - Florian Maul (fme AG)
Alfresco.util: Object functions
• arrayToObject, deepCopy, dotNotation*
Alfresco.util: Array manipulation
• findInArray
• arrayContains
• arrayRemove
• arrayIndex
Alfresco.util: Strings / Formatting
• pad, trim, combinePaths
Alfresco.util: Date conversion
Alfresco.util: DOM / HTML
• getScrollPosition = function()
• insertAtCursor = function(el, txt)
• selectText = function(elTextbox, nStart, nEnd)
• isVisible = function (el)
• decodeHTML = function(html)
• encodeHTML = function(text, justified)
• encodeURIPath = function(text)activateLinks = function(text)
• tweetToHTML = function(text)setSelectedIndex = function(selectEl, value)
• setSelectedClass = function(parentEl, selectEl, selectClass)
• useAsButton = function(el, callbackFn, callbackObj, callbackScope)
 Helper function to listen for mouse click and keyboard enter events on an
• element.generateDomId = function(p_el, p_prefix)
 Returns a unique DOM ID for dynamically-created content. Optionally applies the new
ID to an element.
Alfresco.util: YUI
• createYUIButton = function(p_scope, p_name, p_onclick, p_obj,
p_oElement)
• disableYUIButton = function(p_button)
• enableYUIButton = function(p_button)
• createTwister = function(p_controller, p_filterName, p_config)
• createYUIPanel = function(p_el, p_params, p_custom)
• createInfoBalloon = function(p_context, p_params)
• createBalloon = function(p_context, p_params)
• createInsituEditor = function(p_context, p_params, p_callback)
• findEventClass = function(p_eventTarget, p_tagName)
• hasEventInterest = function(p_eventGroup, p_args)
Editor that is used for inline editing in the document library
for document names and tags:
Alfresco.util.createInsituEditor(context, params, callback);
Alfresco.util: Insitueditor
Alfresco.util: Insitueditor
Alfresco.util.PopupManager
A.u.PopupManager.displayForm
Alfresco.util.PopupManager.displayForm({
title:"Form Title",
properties:{
itemKind:"type",
mode:"create",
itemId:"cm:content",
destination:"workspace://SpacesStore/34c94d94-6418-42dc-9bc7-038693990408",
success: function() {
console.log(
"Node Created.");}
}
}
);
A.u.PopupManager.displayWebscript
• Display the html contents of a webscript in a
Dialog
• If you need OK, Cancel Buttons you have to
provide them in the HTML
Alfresco.util.PopupManager.displayWebscript({
title: "Index",
url: Alfresco.constants.PROXY_URI +"index",
properties:{}
});
Alfresco.util.Ajax
• Use Alfresco Ajax for CSRF support!
 Alfresco.util.Ajax.jsonGet
 Alfresco.util.Ajax.jsonPost
 Alfresco.util.Ajax.jsonPut
 Alfresco.util.Ajax.jsonDelete
• All use:  jsonRequest()
Alfresco.util.Ajax.jsonGet
Alfresco.util.Ajax.jsonGet({
url: Alfresco.constants.PROXY_URI + "index",
successCallback: {
fn: function(result) {
console.log(result.serverResponse.responseText);
},
scope: this
}
});
More URL helpers
Alfresco.util.getVar / setVar
Alfresco.util.setVar("fme", "it's possible");
Alfresco.util.getVar("fme");
Caution: Data is stored as a JSON object on window.name and survives page
requests but it is NOT available when the user opens a new tab!
(It‘s used internally for tracking if flash is available in the browser)
Alfresco.Location component
• Renders the Breadcrumb
l = new Alfresco.Location("template_x002e_title_x002e_repository");
l.setOptions({rootNode:"workspace://SpacesStore/743b079b-a847-4fc2-9a38-
5b3f38638784"});
l.displayByNodeRef("workspace://SpacesStore/2fc3c755-3e4a-4730-a22e-604c2092746b");
Alfresco.Favorite component
• Component to render a Favorite link with action:
f = new Alfresco.Favourite("page_x002e_title_x002e_user_x007e_admin_x007e_dashboard");
f.setOptions({
nodeRef : "workspace://SpacesStore/f3bb5d08-9fd1-46da-a94a-97f20f1ef208"
});
f.render();
Alfresco.Like component
• Render a „like“ link with like action (Ajax reload)
l = new Alfresco.Like("page_x002e_title_x002e_user_x007e_admin_x007e_dashboard");
l.setOptions(nodeRef : "workspace://SpacesStore/f3bb5d08-9fd1-46da-a94a-
97f20f1ef208");
l.render();
Alfresco.logger
Use cheat code:
Ctrl, Ctrl, Shift, Shift
Alfresco.constants (1/2)
• Alfresco.constants.DEBUG = true;
• Alfresco.constants.AUTOLOGGING = false;
• Alfresco.constants.PROXY_URI = window.location.protocol + "//" + window.location.host +
"/share/proxy/alfresco/";
• Alfresco.constants.PROXY_URI_RELATIVE = "/share/proxy/alfresco/";
• Alfresco.constants.PROXY_FEED_URI = window.location.protocol + "//" + window.location.host +
"/share/proxy/alfresco-feed/";
• Alfresco.constants.THEME = "fmeTheme";
• Alfresco.constants.URL_CONTEXT = "/share/";
• Alfresco.constants.URL_RESCONTEXT = "/share/res/";
• Alfresco.constants.URL_PAGECONTEXT = "/share/page/";
• Alfresco.constants.URL_SERVICECONTEXT = "/share/service/";
• Alfresco.constants.URL_FEEDSERVICECONTEXT = "/share/feedservice/";
• Alfresco.constants.USERNAME = "admin";
• Alfresco.constants.SITE = "";
• Alfresco.constants.PAGEID = "";
• Alfresco.constants.PORTLET = false;
• Alfresco.constants.PORTLET_URL = unescape("");
• Alfresco.constants.JS_LOCALE = "en_US";
Alfresco.constants (2/2)
Alfresco.constants.URI_TEMPLATES =
{
"sitedashboardpage": "/site/{site}/dashboard",
"sitepage": "/site/{site}/{pageid}",
"userdashboardpage": "/user/{userid}/dashboard",
"userpage": "/user/{userid}/{pageid}",
"userprofilepage": "/user/{userid}/profile",
"userdefaultpage": "/user/{pageid}",
"consoletoolpage": "/console/{pageid}/{toolid}",
"consolepage": "/console/{pageid}"
};
Alfresco.constants.HELP_PAGES =
{
"share-help": "http://docs.alfresco.com/4.1/topic/com.alfresco.enterprise.doc/topics/sh-uh-welcome.html",
"share-tutorial": "http://docs.alfresco.com/4.1/topic/com.alfresco.enterprise.doc/topics/alfresco-video-
tutorials.html"
};
Alfresco.Share
Alfresco.Share.postActivity("swsdp",
"file-liked",
"inv I200-109.png",
"document-details", {
nodeRef: "workspace://SpacesStore/
723a0cff-3fce-495d-baa3-a3cd245ea5dc"});
Alfresco.component.SimpleDocList
• Component to create document lists
• e.g. used in My Documents dashlet
Alfresco.component.Base
Alfresco.component.Base
(function()
{
FME.MyComponent = function(htmlId, options)
{
this.name = "FME.MyComponent";
this.id = htmlId;
this.setOptions(options);
FME.MyComponent.superclass.constructor.call(this,
this.name, this.id,
["button", "container", "connection", "dragdrop", "json" ]);
return this;
};
YAHOO.lang.extend(FME.MyComponent, Alfresco.component.Base,
{
onReady: function FMC_onReady() {
// add you initialization here
}
});
})();
Alfresco.component.Base
• Creates Button and adds listeners
<button type="alfresco-button" name=".onRenameClick"
value="${nodeRef}">${msg("button.rename")}</button>
• Creates Links and creates events
<a href="#" name"@metaDataRefresh"
class="${args.htmlid?js_string}"
rel="${nodeRef}">${msg("link.metaDataRefresh“)}</a>
Alfresco.util.DataTable
Alfresco.util.DataTable
dt = new Alfresco.util.DataTable(
{
dataTable:
{
container: "template_x002e_people-finder_x002e_people-finder_x0023_default-body",
columnDefinitions:
[
{ key: "name", sortable: false, formatter: function(elCell, oRecord, oColumn, oData) {
elCell.innerHTML = oRecord.getData("fileName");
}
},
{ key: "type", sortable: false, formatter: function(elCell, oRecord, oColumn, oData) {
elCell.innerHTML = oRecord.getData("node").type;
}
}
]
},
dataSource:
{
url:
"/share/service/components/documentlibrary/data/doclist/all/node/alfresco/company/home/Data%20Dictionary?filter=path&size=50&po
s=1&sortAsc=true&sortField=cm%3Aname&libraryRoot=alfresco%3A%2F%2Fcompany%2Fhome&view=browse",
config:
{
responseSchema:
{
resultsList: "items",
metaFields:
{
paginationRecordOffset: "startIndex",
totalRecords: "totalRecords",
totalRecordsUpper : "totalRecordsUpper"
}
}
}
},
paginator:
{
config:
{
containers: ["global_x002e_header_x0023_default-userItems"],
rowsPerPage: 10
}
}
});
Alfresco.util.ComponentManager
• Some Alfresco components are registered with the Component Manager:
Alfresco.Deferred
• Wait for multiple events and execute a callback:
Alfresco.util.bind()
• Changes the this context of a function (binds it to a specific object)
Questions, Feedback …?
33
#237191 - © fme AG34

Mais conteúdo relacionado

Mais procurados

AST Rewriting Using recast and esprima
AST Rewriting Using recast and esprimaAST Rewriting Using recast and esprima
AST Rewriting Using recast and esprimaStephen Vance
 
Building Lithium Apps
Building Lithium AppsBuilding Lithium Apps
Building Lithium AppsNate Abele
 
Letswift19-clean-architecture
Letswift19-clean-architectureLetswift19-clean-architecture
Letswift19-clean-architectureJung Kim
 
Be RESTful (Symfony Camp 2008)
Be RESTful (Symfony Camp 2008)Be RESTful (Symfony Camp 2008)
Be RESTful (Symfony Camp 2008)Fabien Potencier
 
New SPL Features in PHP 5.3
New SPL Features in PHP 5.3New SPL Features in PHP 5.3
New SPL Features in PHP 5.3Matthew Turland
 
An Intro To ES6
An Intro To ES6An Intro To ES6
An Intro To ES6FITC
 
Odoo - From v7 to v8: the new api
Odoo - From v7 to v8: the new apiOdoo - From v7 to v8: the new api
Odoo - From v7 to v8: the new apiOdoo
 
Your Second iPhone App - Code Listings
Your Second iPhone App - Code ListingsYour Second iPhone App - Code Listings
Your Second iPhone App - Code ListingsVu Tran Lam
 
Learn You a Functional JavaScript for Great Good
Learn You a Functional JavaScript for Great GoodLearn You a Functional JavaScript for Great Good
Learn You a Functional JavaScript for Great GoodMike Harris
 
The state of your own hypertext preprocessor
The state of your own hypertext preprocessorThe state of your own hypertext preprocessor
The state of your own hypertext preprocessorAlessandro Nadalin
 
Swift와 Objective-C를 함께 쓰는 방법
Swift와 Objective-C를 함께 쓰는 방법Swift와 Objective-C를 함께 쓰는 방법
Swift와 Objective-C를 함께 쓰는 방법Jung Kim
 
Webエンジニアから見たiOS5
Webエンジニアから見たiOS5Webエンジニアから見たiOS5
Webエンジニアから見たiOS5Satoshi Asano
 
AST - the only true tool for building JavaScript
AST - the only true tool for building JavaScriptAST - the only true tool for building JavaScript
AST - the only true tool for building JavaScriptIngvar Stepanyan
 

Mais procurados (20)

AST Rewriting Using recast and esprima
AST Rewriting Using recast and esprimaAST Rewriting Using recast and esprima
AST Rewriting Using recast and esprima
 
Building Lithium Apps
Building Lithium AppsBuilding Lithium Apps
Building Lithium Apps
 
Letswift19-clean-architecture
Letswift19-clean-architectureLetswift19-clean-architecture
Letswift19-clean-architecture
 
Be RESTful (Symfony Camp 2008)
Be RESTful (Symfony Camp 2008)Be RESTful (Symfony Camp 2008)
Be RESTful (Symfony Camp 2008)
 
I os 04
I os 04I os 04
I os 04
 
New SPL Features in PHP 5.3
New SPL Features in PHP 5.3New SPL Features in PHP 5.3
New SPL Features in PHP 5.3
 
An Intro To ES6
An Intro To ES6An Intro To ES6
An Intro To ES6
 
Odoo - From v7 to v8: the new api
Odoo - From v7 to v8: the new apiOdoo - From v7 to v8: the new api
Odoo - From v7 to v8: the new api
 
AkJS Meetup - ES6++
AkJS Meetup -  ES6++AkJS Meetup -  ES6++
AkJS Meetup - ES6++
 
Your Second iPhone App - Code Listings
Your Second iPhone App - Code ListingsYour Second iPhone App - Code Listings
Your Second iPhone App - Code Listings
 
Epic South Disasters
Epic South DisastersEpic South Disasters
Epic South Disasters
 
Rust ⇋ JavaScript
Rust ⇋ JavaScriptRust ⇋ JavaScript
Rust ⇋ JavaScript
 
Learn You a Functional JavaScript for Great Good
Learn You a Functional JavaScript for Great GoodLearn You a Functional JavaScript for Great Good
Learn You a Functional JavaScript for Great Good
 
The state of your own hypertext preprocessor
The state of your own hypertext preprocessorThe state of your own hypertext preprocessor
The state of your own hypertext preprocessor
 
Command Liner with Scala
Command Liner with ScalaCommand Liner with Scala
Command Liner with Scala
 
Swift와 Objective-C를 함께 쓰는 방법
Swift와 Objective-C를 함께 쓰는 방법Swift와 Objective-C를 함께 쓰는 방법
Swift와 Objective-C를 함께 쓰는 방법
 
XQuery Rocks
XQuery RocksXQuery Rocks
XQuery Rocks
 
Webエンジニアから見たiOS5
Webエンジニアから見たiOS5Webエンジニアから見たiOS5
Webエンジニアから見たiOS5
 
AST - the only true tool for building JavaScript
AST - the only true tool for building JavaScriptAST - the only true tool for building JavaScript
AST - the only true tool for building JavaScript
 
Intro to The PHP SPL
Intro to The PHP SPLIntro to The PHP SPL
Intro to The PHP SPL
 

Semelhante a fme Alfresco Day 06-2013 - alfresco.js and share

Art of Javascript
Art of JavascriptArt of Javascript
Art of JavascriptTarek Yehia
 
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6Dmitry Soshnikov
 
JavaScript Growing Up
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing UpDavid Padbury
 
Swift, functional programming, and the future of Objective-C
Swift, functional programming, and the future of Objective-CSwift, functional programming, and the future of Objective-C
Swift, functional programming, and the future of Objective-CAlexis Gallagher
 
OOP Adventures with XOOPS
OOP Adventures with XOOPSOOP Adventures with XOOPS
OOP Adventures with XOOPSxoopsproject
 
Advanced symfony Techniques
Advanced symfony TechniquesAdvanced symfony Techniques
Advanced symfony TechniquesKris Wallsmith
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...Fabio Franzini
 
Building Smart Async Functions For Mobile
Building Smart Async Functions For MobileBuilding Smart Async Functions For Mobile
Building Smart Async Functions For MobileGlan Thomas
 
Ember background basics
Ember background basicsEmber background basics
Ember background basicsPhilipp Fehre
 
Awesomeness of JavaScript…almost
Awesomeness of JavaScript…almostAwesomeness of JavaScript…almost
Awesomeness of JavaScript…almostQuinton Sheppard
 
DjangoCon US 2011 - Monkeying around at New Relic
DjangoCon US 2011 - Monkeying around at New RelicDjangoCon US 2011 - Monkeying around at New Relic
DjangoCon US 2011 - Monkeying around at New RelicGraham Dumpleton
 
Djangocon11: Monkeying around at New Relic
Djangocon11: Monkeying around at New RelicDjangocon11: Monkeying around at New Relic
Djangocon11: Monkeying around at New RelicNew Relic
 
SenchaCon 2016: Building a Faceted Catalog of Video Game Assets Using Ext JS ...
SenchaCon 2016: Building a Faceted Catalog of Video Game Assets Using Ext JS ...SenchaCon 2016: Building a Faceted Catalog of Video Game Assets Using Ext JS ...
SenchaCon 2016: Building a Faceted Catalog of Video Game Assets Using Ext JS ...Sencha
 
Come on, PHP 5.4!
Come on, PHP 5.4!Come on, PHP 5.4!
Come on, PHP 5.4!paulgao
 
QConSP 2015 - Dicas de Performance para Aplicações Web
QConSP 2015 - Dicas de Performance para Aplicações WebQConSP 2015 - Dicas de Performance para Aplicações Web
QConSP 2015 - Dicas de Performance para Aplicações WebFabio Akita
 
Backbone.js Simple Tutorial
Backbone.js Simple TutorialBackbone.js Simple Tutorial
Backbone.js Simple Tutorial추근 문
 

Semelhante a fme Alfresco Day 06-2013 - alfresco.js and share (20)

Art of Javascript
Art of JavascriptArt of Javascript
Art of Javascript
 
Gephi Toolkit Tutorial
Gephi Toolkit TutorialGephi Toolkit Tutorial
Gephi Toolkit Tutorial
 
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
 
JavaScript Growing Up
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing Up
 
Jquery Fundamentals
Jquery FundamentalsJquery Fundamentals
Jquery Fundamentals
 
Swift, functional programming, and the future of Objective-C
Swift, functional programming, and the future of Objective-CSwift, functional programming, and the future of Objective-C
Swift, functional programming, and the future of Objective-C
 
OOP Adventures with XOOPS
OOP Adventures with XOOPSOOP Adventures with XOOPS
OOP Adventures with XOOPS
 
Advanced symfony Techniques
Advanced symfony TechniquesAdvanced symfony Techniques
Advanced symfony Techniques
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...
 
Building Smart Async Functions For Mobile
Building Smart Async Functions For MobileBuilding Smart Async Functions For Mobile
Building Smart Async Functions For Mobile
 
JS Essence
JS EssenceJS Essence
JS Essence
 
Ember background basics
Ember background basicsEmber background basics
Ember background basics
 
Backbone js
Backbone jsBackbone js
Backbone js
 
Awesomeness of JavaScript…almost
Awesomeness of JavaScript…almostAwesomeness of JavaScript…almost
Awesomeness of JavaScript…almost
 
DjangoCon US 2011 - Monkeying around at New Relic
DjangoCon US 2011 - Monkeying around at New RelicDjangoCon US 2011 - Monkeying around at New Relic
DjangoCon US 2011 - Monkeying around at New Relic
 
Djangocon11: Monkeying around at New Relic
Djangocon11: Monkeying around at New RelicDjangocon11: Monkeying around at New Relic
Djangocon11: Monkeying around at New Relic
 
SenchaCon 2016: Building a Faceted Catalog of Video Game Assets Using Ext JS ...
SenchaCon 2016: Building a Faceted Catalog of Video Game Assets Using Ext JS ...SenchaCon 2016: Building a Faceted Catalog of Video Game Assets Using Ext JS ...
SenchaCon 2016: Building a Faceted Catalog of Video Game Assets Using Ext JS ...
 
Come on, PHP 5.4!
Come on, PHP 5.4!Come on, PHP 5.4!
Come on, PHP 5.4!
 
QConSP 2015 - Dicas de Performance para Aplicações Web
QConSP 2015 - Dicas de Performance para Aplicações WebQConSP 2015 - Dicas de Performance para Aplicações Web
QConSP 2015 - Dicas de Performance para Aplicações Web
 
Backbone.js Simple Tutorial
Backbone.js Simple TutorialBackbone.js Simple Tutorial
Backbone.js Simple Tutorial
 

Último

Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 

Último (20)

Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 

fme Alfresco Day 06-2013 - alfresco.js and share

  • 1. alfresco.js / share.js Hidden gems in Alfresco Client-Side Javascript 2013-06-27 - Florian Maul (fme AG)
  • 2. Alfresco.util: Object functions • arrayToObject, deepCopy, dotNotation*
  • 3. Alfresco.util: Array manipulation • findInArray • arrayContains • arrayRemove • arrayIndex
  • 4. Alfresco.util: Strings / Formatting • pad, trim, combinePaths
  • 6. Alfresco.util: DOM / HTML • getScrollPosition = function() • insertAtCursor = function(el, txt) • selectText = function(elTextbox, nStart, nEnd) • isVisible = function (el) • decodeHTML = function(html) • encodeHTML = function(text, justified) • encodeURIPath = function(text)activateLinks = function(text) • tweetToHTML = function(text)setSelectedIndex = function(selectEl, value) • setSelectedClass = function(parentEl, selectEl, selectClass) • useAsButton = function(el, callbackFn, callbackObj, callbackScope)  Helper function to listen for mouse click and keyboard enter events on an • element.generateDomId = function(p_el, p_prefix)  Returns a unique DOM ID for dynamically-created content. Optionally applies the new ID to an element.
  • 7. Alfresco.util: YUI • createYUIButton = function(p_scope, p_name, p_onclick, p_obj, p_oElement) • disableYUIButton = function(p_button) • enableYUIButton = function(p_button) • createTwister = function(p_controller, p_filterName, p_config) • createYUIPanel = function(p_el, p_params, p_custom) • createInfoBalloon = function(p_context, p_params) • createBalloon = function(p_context, p_params) • createInsituEditor = function(p_context, p_params, p_callback) • findEventClass = function(p_eventTarget, p_tagName) • hasEventInterest = function(p_eventGroup, p_args)
  • 8. Editor that is used for inline editing in the document library for document names and tags: Alfresco.util.createInsituEditor(context, params, callback); Alfresco.util: Insitueditor
  • 12. A.u.PopupManager.displayWebscript • Display the html contents of a webscript in a Dialog • If you need OK, Cancel Buttons you have to provide them in the HTML Alfresco.util.PopupManager.displayWebscript({ title: "Index", url: Alfresco.constants.PROXY_URI +"index", properties:{} });
  • 13. Alfresco.util.Ajax • Use Alfresco Ajax for CSRF support!  Alfresco.util.Ajax.jsonGet  Alfresco.util.Ajax.jsonPost  Alfresco.util.Ajax.jsonPut  Alfresco.util.Ajax.jsonDelete • All use:  jsonRequest()
  • 14. Alfresco.util.Ajax.jsonGet Alfresco.util.Ajax.jsonGet({ url: Alfresco.constants.PROXY_URI + "index", successCallback: { fn: function(result) { console.log(result.serverResponse.responseText); }, scope: this } });
  • 16. Alfresco.util.getVar / setVar Alfresco.util.setVar("fme", "it's possible"); Alfresco.util.getVar("fme"); Caution: Data is stored as a JSON object on window.name and survives page requests but it is NOT available when the user opens a new tab! (It‘s used internally for tracking if flash is available in the browser)
  • 17. Alfresco.Location component • Renders the Breadcrumb l = new Alfresco.Location("template_x002e_title_x002e_repository"); l.setOptions({rootNode:"workspace://SpacesStore/743b079b-a847-4fc2-9a38- 5b3f38638784"}); l.displayByNodeRef("workspace://SpacesStore/2fc3c755-3e4a-4730-a22e-604c2092746b");
  • 18. Alfresco.Favorite component • Component to render a Favorite link with action: f = new Alfresco.Favourite("page_x002e_title_x002e_user_x007e_admin_x007e_dashboard"); f.setOptions({ nodeRef : "workspace://SpacesStore/f3bb5d08-9fd1-46da-a94a-97f20f1ef208" }); f.render();
  • 19. Alfresco.Like component • Render a „like“ link with like action (Ajax reload) l = new Alfresco.Like("page_x002e_title_x002e_user_x007e_admin_x007e_dashboard"); l.setOptions(nodeRef : "workspace://SpacesStore/f3bb5d08-9fd1-46da-a94a- 97f20f1ef208"); l.render();
  • 21. Alfresco.constants (1/2) • Alfresco.constants.DEBUG = true; • Alfresco.constants.AUTOLOGGING = false; • Alfresco.constants.PROXY_URI = window.location.protocol + "//" + window.location.host + "/share/proxy/alfresco/"; • Alfresco.constants.PROXY_URI_RELATIVE = "/share/proxy/alfresco/"; • Alfresco.constants.PROXY_FEED_URI = window.location.protocol + "//" + window.location.host + "/share/proxy/alfresco-feed/"; • Alfresco.constants.THEME = "fmeTheme"; • Alfresco.constants.URL_CONTEXT = "/share/"; • Alfresco.constants.URL_RESCONTEXT = "/share/res/"; • Alfresco.constants.URL_PAGECONTEXT = "/share/page/"; • Alfresco.constants.URL_SERVICECONTEXT = "/share/service/"; • Alfresco.constants.URL_FEEDSERVICECONTEXT = "/share/feedservice/"; • Alfresco.constants.USERNAME = "admin"; • Alfresco.constants.SITE = ""; • Alfresco.constants.PAGEID = ""; • Alfresco.constants.PORTLET = false; • Alfresco.constants.PORTLET_URL = unescape(""); • Alfresco.constants.JS_LOCALE = "en_US";
  • 22. Alfresco.constants (2/2) Alfresco.constants.URI_TEMPLATES = { "sitedashboardpage": "/site/{site}/dashboard", "sitepage": "/site/{site}/{pageid}", "userdashboardpage": "/user/{userid}/dashboard", "userpage": "/user/{userid}/{pageid}", "userprofilepage": "/user/{userid}/profile", "userdefaultpage": "/user/{pageid}", "consoletoolpage": "/console/{pageid}/{toolid}", "consolepage": "/console/{pageid}" }; Alfresco.constants.HELP_PAGES = { "share-help": "http://docs.alfresco.com/4.1/topic/com.alfresco.enterprise.doc/topics/sh-uh-welcome.html", "share-tutorial": "http://docs.alfresco.com/4.1/topic/com.alfresco.enterprise.doc/topics/alfresco-video- tutorials.html" };
  • 24. Alfresco.component.SimpleDocList • Component to create document lists • e.g. used in My Documents dashlet
  • 26. Alfresco.component.Base (function() { FME.MyComponent = function(htmlId, options) { this.name = "FME.MyComponent"; this.id = htmlId; this.setOptions(options); FME.MyComponent.superclass.constructor.call(this, this.name, this.id, ["button", "container", "connection", "dragdrop", "json" ]); return this; }; YAHOO.lang.extend(FME.MyComponent, Alfresco.component.Base, { onReady: function FMC_onReady() { // add you initialization here } }); })();
  • 27. Alfresco.component.Base • Creates Button and adds listeners <button type="alfresco-button" name=".onRenameClick" value="${nodeRef}">${msg("button.rename")}</button> • Creates Links and creates events <a href="#" name"@metaDataRefresh" class="${args.htmlid?js_string}" rel="${nodeRef}">${msg("link.metaDataRefresh“)}</a>
  • 29. Alfresco.util.DataTable dt = new Alfresco.util.DataTable( { dataTable: { container: "template_x002e_people-finder_x002e_people-finder_x0023_default-body", columnDefinitions: [ { key: "name", sortable: false, formatter: function(elCell, oRecord, oColumn, oData) { elCell.innerHTML = oRecord.getData("fileName"); } }, { key: "type", sortable: false, formatter: function(elCell, oRecord, oColumn, oData) { elCell.innerHTML = oRecord.getData("node").type; } } ] }, dataSource: { url: "/share/service/components/documentlibrary/data/doclist/all/node/alfresco/company/home/Data%20Dictionary?filter=path&size=50&po s=1&sortAsc=true&sortField=cm%3Aname&libraryRoot=alfresco%3A%2F%2Fcompany%2Fhome&view=browse", config: { responseSchema: { resultsList: "items", metaFields: { paginationRecordOffset: "startIndex", totalRecords: "totalRecords", totalRecordsUpper : "totalRecordsUpper" } } } }, paginator: { config: { containers: ["global_x002e_header_x0023_default-userItems"], rowsPerPage: 10 } } });
  • 30. Alfresco.util.ComponentManager • Some Alfresco components are registered with the Component Manager:
  • 31. Alfresco.Deferred • Wait for multiple events and execute a callback:
  • 32. Alfresco.util.bind() • Changes the this context of a function (binds it to a specific object)
  • 34. #237191 - © fme AG34