From 76bd720145508c44b9e472b286fa04ff4599b906 Mon Sep 17 00:00:00 2001 From: "Xiaoyang Yu (Max)" Date: Tue, 21 Aug 2012 12:01:58 +0800 Subject: [PATCH 01/26] [Properties] Highlight changed property --- src/js/views/property.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/js/views/property.js b/src/js/views/property.js index 218f66cd..296497a2 100644 --- a/src/js/views/property.js +++ b/src/js/views/property.js @@ -81,12 +81,20 @@ }, _modelUpdatedHandler: function(event, widget) { + var affectedWidget, id; + widget = widget || this; if (event && (event.type === "propertyChanged" && event.node.getType() === 'Design')) { return; } else { widget.refresh(event,widget); + if(event.type === 'propertyChanged') { + id = event.property + '-value'; + affectedWidget = widget.element.find('#' + id); + affectedWidget[0].scrollIntoViewIfNeeded(); + affectedWidget.effect("highlight", {}, 1000); + } } }, From 60d89fc7d0b3172a90e94dc6de80f6ec130a9bc1 Mon Sep 17 00:00:00 2001 From: Xuqing Kuang Date: Wed, 22 Aug 2012 16:06:00 +0800 Subject: [PATCH 02/26] [Project View] Edit name directly after click on project name. --- src/css/builder.css | 5 +++++ src/js/views/project.js | 30 +++++++++++++++++++++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/css/builder.css b/src/css/builder.css index 6ec9b547..d5c76ff7 100644 --- a/src/css/builder.css +++ b/src/css/builder.css @@ -1344,6 +1344,11 @@ div.propertyItems label[for|=id] { font-weight: bold; } +.titleBar input { + width: 150px; + margin: 3px; +} + .openButton { background-image: url("images/openButton_up.png"); background-repeat: no-repeat; diff --git a/src/js/views/project.js b/src/js/views/project.js index 6d82e466..453752f5 100644 --- a/src/js/views/project.js +++ b/src/js/views/project.js @@ -361,7 +361,34 @@ '-webkit-transform-origin':'2 2'}); }, _buttonEvents: function(box, pid, widget) { - var openHandler, cloneHandler, deleteHandler; + var renameHandler, openHandler, cloneHandler, deleteHandler; + renameHandler = function(e) { + var spanElement = $(this), + renameProject = function(e, inputElement, spanElement) { + var projectName = inputElement.val(); + if (projectName.trim() == '') + projectName = 'Untitled' + $.rib.pmUtils.setProperty(pid, "name", projectName); + spanElement.html(projectName); + spanElement.show(); + inputElement.remove(); + }; + + spanElement.hide(); + $('') + .attr('type', 'text') + .val(spanElement.html()) + .appendTo(spanElement.parent()) + .keydown(function(e) { + if(e.keyCode == '13') { + renameProject(e, $(this), spanElement); + } + }) + .blur(function(e) { + renameProject(e, $(this), spanElement); + }) + .focus(); + }; openHandler = function () { var success = function () { // show the layout tab @@ -397,6 +424,7 @@ $.rib.pmUtils.deleteProject(pid, success); }); }; + box.find('.titleBar > span').dblclick(renameHandler); box.find('.openButton').click(openHandler); box.find('.clone.button').click(cloneHandler); box.find('.delete.button').click(deleteHandler); From 5e5e2b0e5bb4c71379631c5a9a847460499c322b Mon Sep 17 00:00:00 2001 From: "Xiaoyang Yu (Max)" Date: Fri, 24 Aug 2012 13:54:36 +0800 Subject: [PATCH 03/26] [Properties] Remove current page id from target list --- src/js/views/property.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/js/views/property.js b/src/js/views/property.js index 218f66cd..978019f0 100644 --- a/src/js/views/property.js +++ b/src/js/views/property.js @@ -96,7 +96,7 @@ p, props, options, code, o, propertyItems, label, value, title = this.element.parent().find('.property_title'), content = this.element.find('.property_content'), - continueToDelete; + continueToDelete, container; // Clear the properties pane when nothing is selected if (node === null || node === undefined) { @@ -385,8 +385,16 @@ value = e.data.value, p = e.data.p; items += '
  • previous page
  • '; + container = node.getParent(); + while (container !== null && + container.getType() !== "Page") { + container = container.getParent(); + } pages = ADM.getDesignRoot().getChildren(); for (o = 0; o < pages.length; o++) { + if (pages[o] === container) { + continue; + } id = pages[o].getProperty('id'); items += '
  • #' + id + '
  • '; } From b471f41b130091654bd2b18939461cbd68967b8e Mon Sep 17 00:00:00 2001 From: yongfeng wu Date: Tue, 31 Jul 2012 16:01:02 +0800 Subject: [PATCH 04/26] [Widgets] Add list widgets --- src/assets/groups.json | 23 +- src/css/images/widgets/jqm_button_list.svg | 44 ++ .../images/widgets/jqm_button_list_item.svg | 28 + src/css/images/widgets/jqm_icon_list.svg | Bin 0 -> 4010 bytes .../images/widgets/jqm_icon_list_button.svg | 26 + src/css/images/widgets/jqm_icon_list_item.svg | Bin 0 -> 2444 bytes .../images/widgets/jqm_icon_split_list.svg | Bin 0 -> 4034 bytes .../widgets/jqm_icon_split_list_item.svg | Bin 0 -> 2468 bytes src/css/images/widgets/jqm_list.svg | 2 +- src/css/images/widgets/jqm_list_item.svg | 2 +- .../images/widgets/jqm_list_split_button.svg | 31 - .../images/widgets/jqm_simple_split_list.svg | Bin 0 -> 4042 bytes .../widgets/jqm_simple_split_list_item.svg | Bin 0 -> 2464 bytes src/css/images/widgets/jqm_text_list.svg | 44 ++ .../images/widgets/jqm_text_list_button.svg | Bin 0 -> 2818 bytes src/css/images/widgets/jqm_text_list_item.svg | 28 + .../images/widgets/jqm_text_split_list.svg | Bin 0 -> 4034 bytes .../widgets/jqm_text_split_list_item.svg | Bin 0 -> 2458 bytes src/css/images/widgets/jqm_thumbnail_list.svg | Bin 0 -> 4028 bytes .../widgets/jqm_thumbnail_list_button.svg | 26 + .../widgets/jqm_thumbnail_list_item.svg | 24 + .../widgets/jqm_thumbnail_split_list.svg | Bin 0 -> 4054 bytes .../widgets/jqm_thumbnail_split_list_item.svg | 24 + src/js/composer.js | 1 + src/js/widgets.js | 573 ++++++++++++++++-- 25 files changed, 779 insertions(+), 97 deletions(-) create mode 100644 src/css/images/widgets/jqm_button_list.svg create mode 100644 src/css/images/widgets/jqm_button_list_item.svg create mode 100644 src/css/images/widgets/jqm_icon_list.svg create mode 100644 src/css/images/widgets/jqm_icon_list_button.svg create mode 100644 src/css/images/widgets/jqm_icon_list_item.svg create mode 100644 src/css/images/widgets/jqm_icon_split_list.svg create mode 100644 src/css/images/widgets/jqm_icon_split_list_item.svg delete mode 100644 src/css/images/widgets/jqm_list_split_button.svg create mode 100644 src/css/images/widgets/jqm_simple_split_list.svg create mode 100644 src/css/images/widgets/jqm_simple_split_list_item.svg create mode 100644 src/css/images/widgets/jqm_text_list.svg create mode 100644 src/css/images/widgets/jqm_text_list_button.svg create mode 100644 src/css/images/widgets/jqm_text_list_item.svg create mode 100644 src/css/images/widgets/jqm_text_split_list.svg create mode 100644 src/css/images/widgets/jqm_text_split_list_item.svg create mode 100644 src/css/images/widgets/jqm_thumbnail_list.svg create mode 100644 src/css/images/widgets/jqm_thumbnail_list_button.svg create mode 100644 src/css/images/widgets/jqm_thumbnail_list_item.svg create mode 100644 src/css/images/widgets/jqm_thumbnail_split_list.svg create mode 100644 src/css/images/widgets/jqm_thumbnail_split_list_item.svg diff --git a/src/assets/groups.json b/src/assets/groups.json index bb05bd01..90c81f47 100644 --- a/src/assets/groups.json +++ b/src/assets/groups.json @@ -21,8 +21,27 @@ "Boolean": ["#0._hidden_node.jqm_input_boolean"] } ], - "List Views": [ - "List", "OrderedList", "ListItem", "ListDivider", "ListButton" + "List Views": [ { + "Ordered List": ["OrderedList", "SimpleListItem", "ListDivider"], + "Unordered Lists": [ { + "Single Lists": [ { + "Simple Single List": ["SimpleList", "SimpleListItem", "ListDivider"], + "Button Single List": ["ButtonList", "ButtonListItem", "ListButton", "ListDivider"], + "Text Single List": ["TextList", "TextListItem", "ListDivider", "TextButton"], + "Icon Single List": ["IconList", "IconListItem", "IconButton", "ListDivider"], + "Thumbnail Single List": ["ThumbnailList", "ThumbnailListItem", "ThumbnailButton", "ListDivider"] + } + ], + "Split Lists": [ { + "Simple Split List": ["SimpleSplitList", "SimpleSplitListItem"], + "Text Split List": ["TextSplitList", "TextSplitListItem", "TextButton"], + "Icon Split List": ["IconSplitList", "IconSplitListItem", "IconButton"], + "Thumbnail Split List": ["ThumbnailSplitList", "ThumbnailSplitListItem", "ThumbnailButton"] + } + ] + } + ] + } ], "Image": ["Image"] } diff --git a/src/css/images/widgets/jqm_button_list.svg b/src/css/images/widgets/jqm_button_list.svg new file mode 100644 index 00000000..647be337 --- /dev/null +++ b/src/css/images/widgets/jqm_button_list.svg @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + +Button List + + + + + + + + + diff --git a/src/css/images/widgets/jqm_button_list_item.svg b/src/css/images/widgets/jqm_button_list_item.svg new file mode 100644 index 00000000..097e1803 --- /dev/null +++ b/src/css/images/widgets/jqm_button_list_item.svg @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + +Button List Item + diff --git a/src/css/images/widgets/jqm_icon_list.svg b/src/css/images/widgets/jqm_icon_list.svg new file mode 100644 index 0000000000000000000000000000000000000000..af655fe436b3cc60e9b6fe080629e0ffc403db47 GIT binary patch literal 4010 zcmeHK?@tp!5Pe@U@qakr1DZ(7wNS9u--wc^kRTdk41rQ;wG=D`ipGCkeQ)Nrz0)fc zqu&fjgWY0}#|trruG z#eqh*R7^aJO}Y8NqgrOzb)!g#5}4UTG0GBUY8haJ;AH2 zmMS&2E&89w))?ciJ;l^s*D9ap7@@xTdTtuSSXrFl3C?IuF=^Utj1raxJDNOei?P$#E zT0GKKM*7G!G|c7^wKOPGO)G=LyzX+e#~IIaM1N`=^_V~TF_ikuBtEb@m+_dj`IzsD zj%L!&BkB`odOXEm;zNXQxog9|?2ZG*tW6K9)Vs!W2yYwIr23iVTZ0&FSw!26%DoFU zAM?a@({#eOHf~{t*eI~B{5x0{E=Jqh;fZ9cz*7n5Gq^p%?)Qv0AMr62!J?<0Ch4NOX&4^YNmA2(`8Y`(s)st7BlIPXt6m14v7YEix+p4fq7wxlT2+7)7 zFxh2x(r0qyHki?F!cJmRWm)G8EaJSk%4!pfY?&3IVVm&^t2eo)#a+%TC;U}~ZwzXG zjq{r(RV@0{BYal)6yScJC$a_O%$VPIjls3Ll(X7pT2-)!l({3IX@X4Q=sBbZs_jE& zP3UUSM`s!NF~pZ-8fpD3^Qk;@9IJkd}VAamrPzJi^i;=Cco#%;@YvqzNZ~w-Pe?Nif2GT z7T*^|IUft9|BeO6ht8s?IdVp0!I4v9G?b4}8P`b2B0*6a4++ZeRgoawfzuWFzeR$) zRArY2NRT8C2@A;@Uq7Ehf@X$D&}cLgdSu2vF&ptCW><$-NA9x2iyIFN(Oq(UpPf7A zI^ogpJ${2K(7y#rDwON)tvhnX#va4a-~BEUZWhu#Ge*CkNpcqMGx|U9l|E~~?#aq% z=vSZch5l}FEFSOhP1qI>Z}Fopr5lwHvYM=j7$;vLeh9G$ojLG@@_BWZDATIE`+ptN zd*HYoQ~VG*rfw0}JfRzg*HOA-Do*3^gfe_pp7>WCQ(k5}rX+bhQDRq+{LhZ5nITVT MG@2*Ezd)~=Uk>gw$p8QV literal 0 HcmV?d00001 diff --git a/src/css/images/widgets/jqm_icon_list_button.svg b/src/css/images/widgets/jqm_icon_list_button.svg new file mode 100644 index 00000000..53c6e1f2 --- /dev/null +++ b/src/css/images/widgets/jqm_icon_list_button.svg @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + +Icon List Button + + + diff --git a/src/css/images/widgets/jqm_icon_list_item.svg b/src/css/images/widgets/jqm_icon_list_item.svg new file mode 100644 index 0000000000000000000000000000000000000000..c95fe613c3f0b33ecfd8848f292088d15ea7be72 GIT binary patch literal 2444 zcma);Yfn=_5Qg8cnD`%#@BvAr<+O^W);nHER7enwF@``XP$>mV!J_f6tIxZ8mbRoQ z*_@u;nc2C%GpB!kH}qHo9jc>DXKJaZ6SZ}ut{!Syxk_5#ox$m<34I4{S9^hbs=jtL zkJKVEkM&45bwdr^(y~_dT<`TsYkI-$6LjzKUeku2>5W$4X55)qne|as&fYC^XBp1A zKIj#1+s^~%h28}}rnQgNzK&H7^zZU2@l^Re!v8(!uXt}EvyZn;td|Ro=7ux%27Birf1BuX#$r~xSTO%OURTJqSMq9HOC61!ko|*e zYs|G2R(a%Z)M}p=$j~78dLA^Uv#U5o1mCgdoa_f~u8L|GH};9OO|Bi6byY`rXK-5F zenve8h2{)vuBUZmK{}yoOWVZN0t?&Zu&D#I_PBWp&SGx6L0i-?NlVOholGAG4Xt4F z7%eSm#6;Q=lV(a~f@GvE zA$J$K1v)-qeTqJg*gnFxk#|H+jr|th#Tj4^hUhoVC(F-M1!KTdwXPW=9N5#FarWd)8^;)DoO3gdtJEVi#W!MD*|{Kl8D$H)ALy4+7HgDH z=Dd3vd3ui9n<-{;oXqwnPPw<#&R>8#@Xx~THI%!2376!Zd6}YAj#MpBt3kGc6<5B7 zbd7J3rK8Lbd`&(%hpEr5?y^Ph-VaZ0Li`b(mt*(zAGOm5Ujt&#c-$GDVxBrZrkD|S z7&6nNM+Qu%9684pXS=@=OPngK5}w>cca7N->oz)N)6BHS*=tO)*-JY7Pv-}o`o8}G z*h1>^ulk0Uo1EPPU3NyFF>IRSGq)f1{%W}6RtnjS3PjlqT9kF}Q&xs^DE`BU=f9l? BUa9~9 literal 0 HcmV?d00001 diff --git a/src/css/images/widgets/jqm_icon_split_list.svg b/src/css/images/widgets/jqm_icon_split_list.svg new file mode 100644 index 0000000000000000000000000000000000000000..7293b6dfbb1f73a8ff2078382627d39cdd3fb9ad GIT binary patch literal 4034 zcmeHKT~8BH5IwJ$_#YN{Koe=%77Et-jVOr<38FE^5GaLKOTkj0X#DHyIWv3PUEM-4 z`bKWHyLax~nYr_E=Jw~08XlsL1GEw06b*E7j1~^j!F^02MgentM_lQkPWmoaJJ`3? z6ZEi$S#nj#^AHbk6E{%9B$ly;r+9<+SjRK&KBnw_zSpsdCwPffu14H5iz3H6lsVVe zGWRTVWdm>VoNwumZRHtWn;lbVQfm)Ks2cqY8U;RO{vOi)ebS%vy-l7bt*ujgF_Bmt zNOVob#Io4vyOg_2E#Vx&>U_V%W>1Sdpezkx6Kn&Lc``kfxkg1c!0m~`VzvUgR zq{k!5Q_b{vioL{!2;Xvf!@lf}1Ny8@3#yd6#&f9NHYiE?Gs~|AYqVt^ZPP3FE|h%C z6W2}B3BTI7g&EdHfqCV>L9^;&w5}bVNV*C+)fi$!8}stj!;b#L<+B-Lt3ERK4jEX zT@BjkC?h+D^(C5S;-6)lm1V;1DyDhv;TT5javhGi!dZoYA%5l~bZO6pxS@*Oid11bJz^N>F^SS_zUJFkPPi+e(m? z%Iwmh5=63+>(FTsYq0m+oMy?;gMP7A9};5khsR*(3TV> zlXhq3+|PN>+5Pjop~o8NP#tADQ%gOasI4P)^-$BwRnh{_3`$o`?suSewHK(T>T6f? za4o{~SdVm5H`LHAEo)WJ^Ldb!Y8zR(ygl?%`E zaKD4z9jv4{lGl^-k_UgMK_WIs@IRaCo>*eBLDxprLERUM(7L1`iV zjCu?T%^B8QPwU76cS6;cwu!3+7PiS@QwM16A$bbUVs5)ZThuT~OU!hgOdkggtzh#Q zEiLYhX;*Mq*Bwr~P-2}k{AqCNQ$PDLyp5Dw`V2ak^%QJAW$)~mGP<6i&pp#8irvD8 zOg|^`Cb@BmLvq%^gF1RwiNpQ2jwa)0o?VL`ZHJ6@$jXC%YCa+2X3%uXuA|$Ur8i38 zD*h+S?u)B!Z4;4gm59oHKC8Ja?EV__=8L|J!g)r#y|q^$UEiLf;6t_IH3D_s}A%qeP&H#HbM8EHRGXFePFa|tT>zX0r;Tq=i|2CrU z*R$~w8|gP{!Lb^Bdp}^s}&g&COljgiG?yv`mpJhpQHDtAV$I6<59n zca3+Exg*aHd`&(%hpEr5?y^N>?}uM)Li`b(mt*(zAGOm5Ujt&#__;GY#XNO-Ofe(u zFl44jj|`YjIed;S&UU{gmN->dB|N!@?i#Zv)@^jkrkQDtv)7npvzK)EOXmlkTHap( zwvf8~tG?moCTI6Rm!01(Mqr=4pT@K4j@6v~u=g9p-M3Q6`CBH*WmG20WzeIXYm%}x LoKNw~BcA^P0)t~= literal 0 HcmV?d00001 diff --git a/src/css/images/widgets/jqm_list.svg b/src/css/images/widgets/jqm_list.svg index ff9dd70b..4481b865 100644 --- a/src/css/images/widgets/jqm_list.svg +++ b/src/css/images/widgets/jqm_list.svg @@ -32,7 +32,7 @@ -Unordered List +Simple List diff --git a/src/css/images/widgets/jqm_list_item.svg b/src/css/images/widgets/jqm_list_item.svg index 7703f1a0..00d56daa 100644 --- a/src/css/images/widgets/jqm_list_item.svg +++ b/src/css/images/widgets/jqm_list_item.svg @@ -24,5 +24,5 @@ -List Item +Simple List Item diff --git a/src/css/images/widgets/jqm_list_split_button.svg b/src/css/images/widgets/jqm_list_split_button.svg deleted file mode 100644 index 2411051f..00000000 --- a/src/css/images/widgets/jqm_list_split_button.svg +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - - - - - - -List Split Button - - - - diff --git a/src/css/images/widgets/jqm_simple_split_list.svg b/src/css/images/widgets/jqm_simple_split_list.svg new file mode 100644 index 0000000000000000000000000000000000000000..1542ca00d31cb6be251f3c765a1f62d6c6855d92 GIT binary patch literal 4042 zcmeHKT~8BH5IwJ$_#akyKoe=%77Et-jbDk138FE^G*A{=DFsWxqVcb*=gjPFcXf-! z=$qMWcX#f+GjnI=oVoq}t${lj;s9MlI7Na!j?uv(dbovI#3*5r&xj*Ev?$-~BY#0&Fd7HwJ`;0Se-e}b+O?<#)}>Hi+(kNMok3}w zwbZGxYti4IT4RhGc9k=0U8{UrWQ2z1>zQc`-^$_)ckqeU6qB}%#;9O*w4%+ub{K2z zOS)FDG#WeQNW#_knU7(rIifY?Q#vA>9ja;z+uT>eTG(a`TiB=8K3ATw&OEj~)8-nA zw0NZJjP#LdNX+IDwIr0Orj@~QUU&Gl%Ms6WM1LCm8ZdwIV=VQND|pB1T*E!q<~_bE zIvUAdcd1X98E_Z7sSgpp6wVFn@+%G)vo1ZTQ|~(WA-ru+lj>)IZwWElv50mVm7C{k zKIV>Frs;%lU0lUHu~A}O`ERf+TuipL%^k^BiMtZc=W%U<-LE-s-s62Hh7GIcd~7Al z=b*uyd)#N33+1gvn-Q%lDqYLx93EvZRZmfUN?uf(v$Pp-T^?DRY^%mfU9o%B5R$jG zY_i|k$?nOKn=qsOl%2$+%ChzuSj2hnDXUE^(ljeV!xrNeW^Zy$hpU`dPWV)XZ;Wbx zo#UG(RV;?oBYf6)mEeA#rLtw?%$UD7jKMX#QZUzMXZV`U%~w}Uu3Rzs&lMJvW%E9Z@x;)1dvnJ6&i(FJxoYw%Su|z^wfVb97T1bZ_C2i#^FC+1Q#=C# z^7uY4%Eefy{BtZgKC~A_&5<)13yz!$qoI6+%J`3jJQ5V8>5!oOUK9z^9XMT)|5GH$ zOI3Ddgak>7kg%N2@%c*`Bxq!e1bt0L!hp;;BxWPtVs>?Sb>u!fytwhe5Zx!o581h6 z&J!N}+~X&x68&4Iq(-^U-Z~@K?Av1)`n#V+!pTCq=cnlR^J&h)c}D*SKGSEd*Ev}k z4gKl^KGNSNchKSUi2Rw@m)_K)n)VbgH+f5<8A8lPW`)lCVMW9^cC0^$KSHcR=MH?L zd|#YJs`NtM|GSRrJ#yNPD*gx^Ri}*qJfahb*IBlsDo)e!h%$Up9{F1xRbJ*hsw71` ZQeoGS{MU}Ekui_xYch|7e~Df-KLD+@Izj*d literal 0 HcmV?d00001 diff --git a/src/css/images/widgets/jqm_simple_split_list_item.svg b/src/css/images/widgets/jqm_simple_split_list_item.svg new file mode 100644 index 0000000000000000000000000000000000000000..d3304a98acc6cbe53ff90d56e320bbcc28977284 GIT binary patch literal 2464 zcma);YflqV5QgU~CjN&7KA?%TY|Ew8dP6RfpqL;UV@LyKfodsO3KWcgU47m;J#O8xEB3+tn6M+PcJ0)vet&6N1%74zPw@Yc`!$}s@EqZ71M9`U#^Q~} zV5!*mEcN?+^zLIN#u2?9otM=8X(FLaZD8-p^H)cgG8VGh#)9Y%@w!B=wW3$UTB>Ml zdG>!iSYv97zKS{7pjAH2kfEOYdgU79Sydb(f=jF^Cr3_Atz?xOi6dfdl552!UF96@ z0!oJT67}fyH78h8J*6XY?ue>g+asX|dqgB#1)@@)PubHu?EW6|X2*7NIjlLFhjXjD;TqJadC2=1wNTv} z*i5jhthBtIleU^$LeD6C>V6b9C$Jg&x_D!4*ly^qjI4M16GYQam5?v7)5C092NCM@ zy7!L|yGu-wdmEW1Qlaq?_=xo}`Z!?w1lvO12{{$^GrS8kKpqUxuREQ@KTQ>c0ZrAaO%m~74f6Sa z8^QO7*;vI!{N-&3GxybJ6net!Ntrf^G0ZsSW*AqoM<)C4h(TqaI`3_i&Det9-$q%e zQAC;Yu4$y{Ic#sTKa;~`mN#L_y{C4113ZI%;k$R-%yd|ut z@)fu%yo4L8wu_yf08Jc36Ivu8% z5O(aD>ChuRrc(-^VhgifZ;3@tB~}4X=FnYX_Jq3Sr)->=(m3^iNj7y$hrV>K@l^8q z0+5B+<=^cmUe@uu$@3KKWq#65on7~*FkSbv=5w8sXyR1|ZslYXs?zk%O8ELwevUy% P(Ra$!U^a!Xj&S}5h + + + + + + + + + + + + + + + + + + + + + + + + + +Text List + + + + + + + + + diff --git a/src/css/images/widgets/jqm_text_list_button.svg b/src/css/images/widgets/jqm_text_list_button.svg new file mode 100644 index 0000000000000000000000000000000000000000..7bee4b5c75126c39415cf10c19424ae7eb78aeb5 GIT binary patch literal 2818 zcma);ZBH9l5QXO}k@6oF_&_7YHfvL2J5JIN@+Q#|320SS$O2=)!5C@`F^Tfm+dgOR zUhmqN6s_#tojZ44&YYRM|NhgmS2nhD>sw+s*0rHsSWpIsucDHtBPqAgvK80ty_%ms^S6}e8HPAIrY`ls#c%uI3?E} zSSv5tsuk95Sn0BRgL;fJ%L(38PuWOZJF@D)4#}$v7Y@O&V`o?$vhy0A1#AayEm)Xm zB_Q1d=}WiJb)T15=^_)SRl&TjN4y=g66%}~Pm8w^^-~fr=A&+#c>uxV&CTK#(mQ}&cUot1WoL2lZX0k2TS5liKi|-+H*wvpz{2OmaoXT zf2AYLT{AeRrrsd)fe~sIwT|cDwCD^e8ryJQ5{e~u zdYDZgVT3xp?foOh9*|Si-eXUXU7`1{xr>E66Mk;9zUNZKJI0QBXq~HUKfA@-Oje_B z%5+VfDb+ceLDoQT4ZT%5K5~75J`UWzz_*xp0jA=9m*~O_Py{*qCDWVqOH@G|&{S>O zG8yMrj_3dT2(drR$2)w)U(ts+^P~FAV^5epDbq$dh8ZVprg;^6WH~z{^2$DO-C35c z+B28WvMkgnvP`&Z8fkh?`&-Uta+u7DCQP|sshv)Mr>x)j(+4DLoP-V2lhzUoS}9s} zm)2ajiWgPBj&_~1NZLW?E3w9ygkkKn`@3wNz0dqtpOb%J=WOnp{zX3{_%$Z?gr7P? zQ%qB5$P^R9&K;Q{Ju+rGrRXWQFxz!X)Zuc&Gj1TS`q{3p44u=VDshH|c^jvvY_B|E zrmc8pxea~ud?jY>7mlh*?Dx<1H}ST~B;?d~9*WIvPAq)`sapoFp`OMz zPC9+Z&3YMlCW=4I1f9cYXbG3Q^H(`Vjnd3CuHLax@)JxM>rCopZ$-ovo1%(yQ<-TZ riVt-dF9wJmns8+}QDat0syB6tzAVC?r*Ni + + + + + + + + + + + + + + + + + +Text List Item + diff --git a/src/css/images/widgets/jqm_text_split_list.svg b/src/css/images/widgets/jqm_text_split_list.svg new file mode 100644 index 0000000000000000000000000000000000000000..f9faa17851670501c6f06466ce6fbbad9ff96f9e GIT binary patch literal 4034 zcmeHKT~8BH5IwJ$_#YN{Koe=%77Et-ji?C<37|2?5GaLKOTkj0X#DHyIWv3PUEN|a z@@6*OkGc2G%$=EY=Jv<;8XlsLL$nd$3=MQ~f) zQ}nQpSw=X}b3Y$MO`+WeS8lU92;M%Co!&{g2C%=;1jKcM_MpF5n>q_=fiFD4p` z1C4H}n0OYOe2;qfXeI0;c%2`Y*!*d6g(9^|dlweJZR%3QJgOa9(D*oBml$hZ!Ku+*s@lOW_tju6>@tRRe4^GaSDv!YJhmOv<{I*} zc%-Y0^s#AZn9XBqX;7w`RtAT8-Q(9jM?B9F{i*S*$Nb5Uq0~nv@t)PWjK{3a$9z|G zG?Km^QJ*l=<1Y3SA0m9sog3C=R~#~CZF*3p-Zkz+c-x>R)z2*78pLSJBHCtD?p><+ zggdUArc=JPaSJoVMuBzZ_h4DL7;S5pJCdyecO{(9;Pwc+-!k5Oz=u=}YgWzK*h-eo zL5(^0xKA(_%3GZ_BU)8d+Lq60tfVegPhNdWo>!Ywv>9++99SD|tHMfMwBM2;Bx`HI zWPh@g-jgG@!Hjkjb`p~+%i3pP5$C;^tTwU8wpkGxb{MZPdy8vYT;;rS%BL!PV^I5R z9N#jjV$r7_;j_Z40QdVMku4Z!#=PG(2G{IT&TN-yR>2}t=8Ax(2{MJF=ZGGtwvU)K zp{qe3on_?55MPq%OY>)$XH}VayNYSN;W?sspTNnaTQ z&*6^c{ES~^yx@JF{Z@YKU0o=G&x~#6lF7?t(U=v~Fqkuw?#j+_#sp?rkO_>Y7v5)`HJkf8it6$#QEI9-wdTO`O! zRd#8B1WEFcu#n90`SU3xXk>^4eT_y!kIdL7W+VQ@?CS99$X#}LapR#Ox=W7lvvbFs zCp`MO$4^iN`nNzyg>s#}bw;k(x5qH_cR!1SlZAB8jM49BlAML}jQ$UNq0d^cbFwlT z`qf8#roY?ViSKEfdpR~1?NKV6i<333j-}I;(6Tv*fV!4uDH^NEZ1G0W7dm#}5#{;n z>`|r%^7{HZsrSZlJE?dhbW)uz{_}@U9$sJRPO3PK#~;e@Rr%vzby9hm?WB_A@kfc> WLh|1`sYZtUp|8>W5&j)|)%*l^(m1#P literal 0 HcmV?d00001 diff --git a/src/css/images/widgets/jqm_text_split_list_item.svg b/src/css/images/widgets/jqm_text_split_list_item.svg new file mode 100644 index 0000000000000000000000000000000000000000..30788fadd0c37e034412b28c3750c87a108b6f58 GIT binary patch literal 2458 zcma);TTc^F6ouC-CjN&J9?(Qurd2Gp-VrrXF+nuOm6pepf{nj~iXiJKc zlXhnI{j&C+`SZJ>M;dBhU1d5^TYVj=qXYHyK(oqK(jwOkPERf9+i-i@4cuc5w4(*2 zmXLX*hq|t7YUqYmw5DfzuTOfX=V%{cdzb4wZRn|9>lNG#oduOSA64bqcPr?uz**M^ zz2Iv9dEh+P+YraB_V7B;q3VHtDxVU+D*p$>zYF~Z*G**hh_;3Ia$&K2ZZUc)7m?+G zzKz{&yreu*)YI#dhj=<@xKgk2cNXf`#Fi@-tJ=eZ`B#a$LalvLRFhWfSnP)Cf4j29 zT+88<$8@7r$FxX=h9TCoU@<+ri!)?!iZ|C}FK}~JR6Ez$Bi9bKc3!qs9pjzAX`}s= zehdrC8Q$Da+sJ}+Le-|W$g2$&wy0rC->}+8^BA1P+V+CAXknU_Sm`>IJ`5Jx!RH}X z+R%(?cW~6#ZJu`E#6D-l)8J`9{~X7N8aX%g8Fa4b3D|tXy{lu+_<4*y&&+@ z{hTVB^d>d-sacl@>eyW)56{~=mW-bT?%K>~CsedcRqp@O@(~%gf~8~by1J=(W}^hI z;(zk&xwzcd78%)BiL5;5^SX73-(M5ae9@P&8a4u&Cu?ikWDgqjJl1`NUbt^9d}erc zRl1>{b6OocM$a^Snm!Giv-nJNT|W0V={HVSo2vJV4dQL*PB@k{>2Wu`0ui3{W|$u% zc9Wcv^aeT|wBqa^b2SRr&+)kieVf>vd2N=!}KDU~Ubk+zK7 z9po07_=NQt<~U;e0N+O50W~%D+e8<4fFl^8-!wm2et|9+1Kz52&5`lwjOzJ+A2If; z`B=qA`i=WAX8zTmY3PZ&CuiF@$GGEMn@L=y8JR2I5u?uD3bGebwy1l7ei3D{M+s%F zySI_I=cK>6VkgJV>}cYadqeO12DlCXB;37(a)&qJvV3P=rYMyoRSVQ=kgedwov$HX z<6UIwDD#6@Q%tU5nzPHNYzf_a;a8iIe?;fS+`awB{S3g@klZtVo(yj>Z=F6{%m~{L zmFY7hL$*_noO6r2-EWCyo+_LYk=(_0jolObHoj%k&a}n(D{Qj)3pV_v^MgpO?=Jv* zNK^h*--)tG{4tXz85{-#4xk!|#&eUaC8DJ7{RZ*$y)X3qEtB*zzI&pyJCQ7pwo?4w Hh|hlkF6&|4 literal 0 HcmV?d00001 diff --git a/src/css/images/widgets/jqm_thumbnail_list.svg b/src/css/images/widgets/jqm_thumbnail_list.svg new file mode 100644 index 0000000000000000000000000000000000000000..0538fc87fe5c4601e4ed21b8a63554fae53ac095 GIT binary patch literal 4028 zcmeHKYflqV5ItWp@joo^0ZpW3TPRrT8(#?u37|2?5GaLKOTp4&(fHTZb7uCoySl|< zW$JoMKY~TrZpHlWA-y7J*Bdp;CS0nD3N0H+V%AD(K zm3vmXvWeGt#<%pxw(+&OL(-q|y-S`Zt*ujgF_Bmt zN_0)d#Io4v`;@y+E#Vx&>U_V%W>1SdlurZ)McX{#|xSQ+kU@~kcTTIZ6i zWh@TY&bZRx?njKrAdwtVo8l=Mk#UEt+QlBv)nG2{(T8<>q|`2V_L*ny+m1U|#t%XjWZ}*R{tJNmqfVQk~D?<`})-GSPcasXTb(*1YL!>o7SCBcO$}vFUVe(6mzy)x8S1(?)HYsMg_*i+zZI*Htga=a z{Yg*yOkTMSMzoutlaN$V);R-;IPSe*wh2XcOpB^vm;MUe+uYOQF2|KV-^%dKVeYSU zecPz=#ei~DpB0V*-0t&)wq%$Y^Lg74T->D`Zl{T>U>+%RN2sPLB86AaF)dJTA2VvI zt_E#%l#v~y`Vvhu@y|2P$}-`06|+3|XpAEEXC02Xlj(R$9pRVOp{%?pN_qL|=q3;9 zjEBzW8+*gdYLF1GlQCZE)d1FV}*TBI|ARAly&lFsDNyJ zU*zTdS}0w4EqHzCEb^LH&iGpJ$|=zsibu$d|CNxf1bJz)N>F?+TM3dKFkPPi+e(m? z%Iwmx5=6}_pp{W2Xg0nQdPK$nYc}Ff$gU2rj@)I37d9SQMR$qu19tA1 ze5yyk_xKH}K>Ld7CHV^50#bK9x6&6a+KI7 VME|{qYGs5RnvF+}@W0Tr<|iY=H|78U literal 0 HcmV?d00001 diff --git a/src/css/images/widgets/jqm_thumbnail_list_button.svg b/src/css/images/widgets/jqm_thumbnail_list_button.svg new file mode 100644 index 00000000..2dfb18aa --- /dev/null +++ b/src/css/images/widgets/jqm_thumbnail_list_button.svg @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + +Thumbnail List Button + + + diff --git a/src/css/images/widgets/jqm_thumbnail_list_item.svg b/src/css/images/widgets/jqm_thumbnail_list_item.svg new file mode 100644 index 00000000..659e8a8b --- /dev/null +++ b/src/css/images/widgets/jqm_thumbnail_list_item.svg @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + +Thumbnail List Item + diff --git a/src/css/images/widgets/jqm_thumbnail_split_list.svg b/src/css/images/widgets/jqm_thumbnail_split_list.svg new file mode 100644 index 0000000000000000000000000000000000000000..309ee41939927dbb677eef4545e58bf03e604b80 GIT binary patch literal 4054 zcmeHKYflqV5ItWp@joo^0ZpW3TPRrT1H@ONVuEOlF$7AXl~S;@STz21^_-c#?XGUI z82M&4-N)Q}XXeh#Idl8tdkyz7z!BPraE1oDI7JJ`=-@795Tk$vJ|m8FP^Wy4qa7UB zXdgZ7W1h1roO2)da2?lB!!*{hfrogFcX)+ITzyL22YkN57S`|_&o~-!%{+>{-lEKJ zy{&W2I!89~22c2u{n$nx;idU8gC?!^aDuAIKSNi6zcTN~^#6eJCw%U3PLtl&X}y?e zEDklgrDEb)Z1O$o-J_MTkKlEFTw?R5#TAOwbJ{z%_-#{{BIZ%;(1OM%@w&uV>k3|F zwN$CGZP7oRSYwRab`?`=U8{UrV1x$d>$zzR-^$_?ckr3k6qBZn#wcNBxT49uwis*e zOS+b^I2=3UNQ0}_n2$lCIifY?Q#vA>9ja;vyWCfUwXn+=)^SL!U9Rl2&OEjq)8-oT zw0NYejP!|VXqe3tYH3iWnpOr!dEMjJK1V#y5&fz0tH=DwkCD_zrtzNDxsFxV<|^M6 z9gU=~2h=Cb^tg-t#D@r9bLWP2*%e2OS(_eIsdt0>5Z*SaN%b?&w+1oVvWT`Bl{*(| zKIM++#%3Kl9G)1Ox^c>Rz)%G#7 zCUiCEqqB_s7~xAYeQEwY^Q8Fw-pk7*JxnlA%Su|z^HF;kki)+OS`<_;Wd0$fADV_lV zS$tm<<$NrZt{e-F5A8)!bL5Q2f+MHIXeb|{GX5hWiv&e!G9)O!mqmhf2ToVy{}u`I zQk7jAB0-WoBrGL!eEwnz2^tw8L0{vM&?7Srh}nogF}pgvI&zmCUfg(Oi0+c(2khK2 z=LwH~?(q{;f&MK~QlVUDZ=I1V_U$nY{oT(Z;bbA*a})IYxg=-dJfr^uU+A;e>zu5N zhJN)CpXl$lF;JgxyWGtVN86O?G$y3?_^zkeSu-WkIZL>C%@}6a>FgiYMU1Jh6PJXz zg)SbrMY+E`qm=23c5-#y)%)e7-Bnx?x~onc|2ajc5wE#)cU7Dw;}m81vYhg-x~sg* ec2`OAIHkl6BKhy#RU;!#(bsrR3I7 + + + + + + + + + + + + + + + + +Thumbnail Split List Item + diff --git a/src/js/composer.js b/src/js/composer.js index 7f85a8c7..1719ac6a 100644 --- a/src/js/composer.js +++ b/src/js/composer.js @@ -550,6 +550,7 @@ $(function() { '> .ui-collapsible-content > .adm-node,' + '> ul > li.adm-node,' + '> div > .adm-node,' + + '> div > div > a > .adm-node,' + '> *.orig-adm-node:not(.ui-header,.ui-content,.ui-footer)', start: function(event, ui){ trackOffsets('start: ',ui,$(this).data('sortable')); diff --git a/src/js/widgets.js b/src/js/widgets.js index 292e87f8..afa289c8 100644 --- a/src/js/widgets.js +++ b/src/js/widgets.js @@ -25,6 +25,11 @@ var BCommonProperties = { defaultValue: false, htmlAttribute: "disabled" }, + filter: { + type: "boolean", + defaultValue: false, + htmlAttribute: "data-filter" + }, icon: { type: "datalist", options: [ "none", "alert", "arrow-d", "arrow-l", "arrow-r", @@ -88,6 +93,16 @@ var BCommonProperties = { options: [ "default", "a", "b", "c", "d", "e" ], defaultValue: "default", htmlAttribute: "data-track-theme" + }, + inset: { + type: "boolean", + defaultValue: true, + htmlAttribute: "data-inset", + // because data-inset="false" is the real default, do this: + forceAttribute: true + // FIXME: would be better to distinguish from the default that + // occurs if you leave it off, vs. the default we think + // the user is most likely to want } }; @@ -647,11 +662,10 @@ var BWidgetRegistry = { }, /** - * Represents a button. A "text" string property holds the button text. + * Represents a base button widget */ - Button: { + ButtonBase: { parent: "Base", - paletteImageName: "jqm_button.svg", editable: { selector: "span > .ui-btn-text", propertyName: "text" @@ -691,6 +705,18 @@ var BWidgetRegistry = { defaultValue: "slide", htmlAttribute: "data-transition" }, + }, + template: '%TEXT%' + }, + + /** + * Represents a button. A "text" string property holds the button text. + */ + + Button: { + parent: "ButtonBase", + paletteImageName: "jqm_button.svg", + properties: { icon: BCommonProperties.icon, iconpos: $.extend({}, BCommonProperties.iconpos, { invalidIn: "Navbar" @@ -1351,34 +1377,10 @@ var BWidgetRegistry = { /** * Represents a unordered list element. */ - List: { - parent: "Base", + SimpleList: { + parent: "ListBase", paletteImageName: "jqm_list.svg", - dragHeader: true, properties: { - inset: { - type: "boolean", - defaultValue: true, - htmlAttribute: "data-inset", - // because data-inset="false" is the real default, do this: - forceAttribute: true - // FIXME: would be better to distinguish from the default that - // occurs if you leave it off, vs. the default we think - // the user is most likely to want - }, - theme: BCommonProperties.theme, - divider: { - displayName: "divider theme", - type: "string", - options: [ "default", "a", "b", "c", "d", "e" ], - defaultValue: "default", - htmlAttribute: "data-divider-theme" - }, - filter: { - type: "boolean", - defaultValue: false, - htmlAttribute: "data-filter" - }, filter_theme: $.extend({}, BCommonProperties.theme, { displayName: "filter theme", htmlAttribute: "data-filter-theme" @@ -1391,11 +1393,81 @@ var BWidgetRegistry = { } }, template: '
      ', + }, + + /** + * Represents a unordered button list element. + */ + ButtonList: { + parent: "SimpleList", + paletteImageName: "jqm_button_list.svg", + zones: [ + { + allow: [ "ButtonListItem"] + } + ] + }, + + /** + * Represents a unordered button list element. + */ + TextList: { + parent: "SimpleList", + paletteImageName: "jqm_text_list.svg", + zones: [ + { + allow: [ "TextListItem" ] + } + ] + }, + + /** + * Represents a icon list element. + */ + IconList: { + parent: "SimpleList", + paletteImageName: "jqm_icon_list.svg", + template: '
        ', + zones: [ + { + allow: [ "IconListItem" ] + } + ] + }, + + /** + * Represents a Thumbnail list element. + */ + ThumbnailList: { + parent: "SimpleList", + paletteImageName: "jqm_thumbnail_list.svg", + template: '
          ', + zones: [ + { + allow: [ "ThumbnailListItem" ] + } + ] + }, + /** + * Represents a base List widget + */ + ListBase: { + parent: "Base", + dragHeader: true, + properties: { + inset: BCommonProperties.inset, + filter: BCommonProperties.filter, + theme: BCommonProperties.theme, + divider_theme: $.extend({}, BCommonProperties.theme, { + displayName: "divider theme", + htmlAttribute: "data-divider-theme" + }) + }, zones: [ { name: "default", cardinality: "N", - allow: [ "ListItem", "ListDivider", "ListButton" ] + allow: [ "SimpleListItem", "ListDivider" ] } ], delegate: function (domNode, admNode) { @@ -1413,6 +1485,16 @@ var BWidgetRegistry = { ); // Reconstruct the domNode. return filterForm.wrap(newNode).parent().append(domNode); + }, + init: function (node) { + // initial state is three button ListItem + var i; + for (i = 0; i < 3; i++) { + var listType = node.getType(), itemName = "SimpleListItem"; + if (listType !== "OrderedList") + itemName = listType + "Item"; + node.addChild(ADM.createNode(itemName)); + } } }, @@ -1420,19 +1502,92 @@ var BWidgetRegistry = { * Represents an ordered list element. */ OrderedList: { - parent: "List", + parent: "ListBase", paletteImageName: "jqm_ordered_list.svg", - template: '
            ' + template: '
              ', + }, + + /** + * Represents a Split list element. + */ + ThumbnailSplitList: { + parent: "SimpleSplitList", + paletteImageName: "jqm_thumbnail_split_list.svg", + zones: [ + { + name: "default", + cardinality: "N", + allow: [ "ThumbnailSplitListItem"] + } + ], + }, + + /** + * Represents a Split list element. + */ + SimpleSplitList: { + parent: "ListBase", + paletteImageName: "jqm_simple_split_list.svg", + properties: { + theme: { + type: "string", + options: [ "default", "a", "b", "c", "d", "e" ], + defaultValue: "default", + htmlAttribute: "data-split-theme" + }, + split_icon: { + displayName: "split icon", + type: "string", + options: [ "none", "alert", "arrow-d", "arrow-l", "arrow-r", + "arrow-u", "back", "check", "delete", "forward", + "gear", "grid", "home", "info", "minus", "plus", + "refresh", "search", "star" ], + defaultValue: "none", + htmlAttribute: "data-split-icon" + } + }, + template: '
                ', + zones: [ + { + allow: [ "SimpleSplitListItem"] + } + ] + }, + + /** + * Represents a Split list element. + */ + TextSplitList: { + parent: "SimpleSplitList", + paletteImageName: "jqm_text_split_list.svg", + zones: [ + { + allow: [ "TextSplitListItem"] + } + ] + }, + + /** + * Represents a Split list element. + */ + IconSplitList: { + parent: "SimpleSplitList", + paletteImageName: "jqm_icon_split_list.svg", + zones: [ + { + allow: [ "IconSplitListItem"] + } + ] }, /** * Represents a list item element. */ - ListItem: { + SimpleListItem: { parent: "Base", - displayLabel: "List Item", + displayLabel: "Simple List Item", paletteImageName: "jqm_list_item.svg", - allowIn: [ "List", "OrderedList" ], + allowIn: [ "SimpleList", "OrderedList" ], editable: { selector: "", propertyName: "text" @@ -1440,7 +1595,7 @@ var BWidgetRegistry = { properties: { text: { type: "string", - defaultValue: "List Item" + defaultValue: "", }, theme: BCommonProperties.theme, filtertext: { @@ -1453,24 +1608,207 @@ var BWidgetRegistry = { template: '
              • %TEXT%
              • ' }, + /** + * Represents a list button item element. + */ + ButtonListItem: { + parent: "SimpleListItem", + displayLabel: "Button List Item", + paletteImageName: "jqm_button_list_item.svg", + allowIn: [ "ButtonList" ], + zones: [ + { + name: "default", + cardinality: "1", + allow: [ "ListButton" ] + } + ], + init: function (node) { + node.addChild(ADM.createNode("ListButton")); + } + }, + + /** + * Represents a list text item element. + */ + TextListItem: { + parent: "ButtonListItem", + displayLabel: "Text List Item", + paletteImageName: "jqm_text_list_item.svg", + allowIn: [ "TextList" ], + template: '
              • ', + zones: [ + { + allow: [ "TextButton" ] + }, + ], + init: function (node) { + // initial state is three TextButton + node.addChild(ADM.createNode("TextButton")); + } + }, + + /** + * Represents a IconListItem element. + */ + IconListItem: { + parent: "ButtonListItem", + displayLabel: "Icon List Item", + paletteImageName: "jqm_icon_list_item.svg", + allowIn: [ "IconList" ], + template: '
              • ', + zones: [ + { + allow: [ "IconButton" ] + } + ], + init: function (node) { + // initial state is three buttons + node.addChild(ADM.createNode("IconButton")); + } + }, + + /** + * Represents a ThumbnailListItem element. + */ + ThumbnailListItem: { + parent: "ButtonListItem", + displayLabel: "Thumbnail List Item", + paletteImageName: "jqm_thumbnail_list_item.svg", + allowIn: [ "ThumbnailList"], + template: '
              • ', + zones: [ + { + allow: [ "ThumbnailButton" ] + } + ], + init: function (node) { + // initial state is a ThumbnailButton + node.addChild(ADM.createNode("ThumbnailButton")); + } + }, + + /** + * Represents a SplitListItem element. + */ + ThumbnailSplitListItem: { + parent: "SimpleSplitListItem", + displayLabel: "Thumbnail Split List Item", + paletteImageName: "jqm_thumbnail_split_list_item.svg", + allowIn: [ "ThumbnailSplitList" ], + zones: [ + { + name: "left", + cardinality: "1", + allow: [ "ThumbnailButton" ] + }, + { + name: "right", + cardinality: "1", + allow: [ "ListButton" ] + } + ], + init: function (node) { + // initial state is three buttons + node.addChild(ADM.createNode("ThumbnailButton")); + node.addChild(ADM.createNode("ListButton")); + } + }, + + /** + * Represents a SplitListItem element. + */ + SimpleSplitListItem: { + parent: "ButtonListItem", + displayLabel: "Simple Split List Item", + paletteImageName: "jqm_simple_split_list_item.svg", + allowIn: [ "SimpleSplitList" ], + properties: { + text: { + defaultValue: "List Item", + }, + }, + template: '
              • ', + zones: [ + { + name: "left", + cardinality: "2", + allow: [ "ListButton" ] + } + ], + init: function (node) { + // initial state is three buttons + node.addChild(ADM.createNode("ListButton")); + node.addChild(ADM.createNode("ListButton")); + } + }, + + /** + * Represents a SplitListItem element. + */ + IconSplitListItem: { + parent: "SimpleSplitListItem", + displayLabel: "Icon Split List Item", + paletteImageName: "jqm_icon_split_list_item.svg", + allowIn: [ "IconSplitList" ], + zones: [ + { + name: "left", + cardinality: "1", + allow: [ "IconButton" ] + }, + { + name: "right", + cardinality: "1", + allow: [ "ListButton" ] + } + ], + init: function (node) { + // initial state is three buttons + node.addChild(ADM.createNode("IconButton")); + node.addChild(ADM.createNode("ListButton")); + } + }, + + /** + * Represents a SplitListItem element. + */ + TextSplitListItem: { + parent: "SimpleSplitListItem", + displayLabel: "Text Split List Item", + paletteImageName: "jqm_text_split_list_item.svg", + allowIn: [ "TextSplitList" ], + zones: [ + { + name: "left", + cardinality: "1", + allow: [ "TextButton" ] + }, + { + name: "right", + cardinality: "1", + allow: [ "ListButton" ] + } + ], + init: function (node) { + // initial state is three buttons + node.addChild(ADM.createNode("TextButton")); + node.addChild(ADM.createNode("ListButton")); + } + }, + /** * Represents a list divider element. */ ListDivider: { - parent: "Base", + parent: "SimpleListItem", displayLabel: "List Divider", paletteImageName: "jqm_list_divider.svg", - allowIn: [ "List", "OrderedList" ], - editable: { - selector: "", - propertyName: "text" - }, + allowIn: [ "SimpleList", "OrderedList", "ButtonList", "TextList", "IconList", "ThumbnailList" ], properties: { text: { - type: "string", defaultValue: "List Divider" }, - theme: BCommonProperties.theme }, template: '
              • %TEXT%
              • ' }, @@ -1479,24 +1817,13 @@ var BWidgetRegistry = { * Represents a button. A "text" string property holds the button text. */ ListButton: { - parent: "Base", + parent: "ButtonBase", displayLabel: "List Button", paletteImageName: "jqm_list_button.svg", - allowIn: [ "List", "OrderedList" ], - editable: { - selector: "a", - propertyName: "text" - }, + allowIn: [ "ButtonListItem", "ThumbnailSplitListItem", "SimpleSplitListItem", "TextSplitListItem", "IconSplitListItem" ], properties: { text: { - type: "string", - defaultValue: "Button" - }, - target: { - type: "string", - defaultValue: "", - htmlAttribute: "href", - htmlSelector: "a" + defaultValue: "List Button" }, icon: $.extend({}, BCommonProperties.icon, { options: BCommonProperties.icon.options.slice(1), @@ -1510,8 +1837,7 @@ var BWidgetRegistry = { } }, template: function (node) { - var prop, countBubble, code = $('
              • %TEXT%
              • '); - var anchor = code.find('a'); + var prop, countBubble, code = $('%TEXT%<'); prop = node.getProperty("countbubble"); // Add the count bubble if countbubble property is not blank @@ -1519,12 +1845,135 @@ var BWidgetRegistry = { countBubble = $('') .attr('class', 'ui-li-count') .html(prop); - anchor.append(countBubble); + code.append(countBubble); }; return code; } - + }, + + /** + * Represents a button. A Icon_Image property holds the button text. + */ + IconButton: { + parent: "ButtonBase", + displayLabel: "Icon list Button", + paletteImageName: "jqm_icon_list_button.svg", + allowIn: [ "IconListItem", "IconSplitListItem" ], + properties: { + text: { + defaultValue: "Icon List Item" + }, + iconsrc: { + type: "url-uploadable", + defaultValue: "src/css/images/widgets/tizen_image.svg", + forceAttribute: true + }, + countbubble: { + type: "string", + displayName: "count bubble", + defaultValue: "0" + } + }, + template: function(node) { + var prop, iconsrc, countBubble, code = $('%TEXT%<'); + prop = node.getProperty("countbubble"); + // Add the count bubble if countbubble property is not blank + if (prop.trim() != '') { + countBubble = $('') + .attr('class', 'ui-li-count') + .html(prop); + code.append(countBubble); + }; + prop = node.getProperty("iconsrc"); + // Add the count bubble if iconsrc property is not blank + if (prop.trim() != '') { + iconsrc = $('') + .attr('src', prop) + .attr('width','16') + .attr('class', 'ui-li-icon'); + code.append(iconsrc); + }; + return code; + } + }, + + /** + * Represents a button. A Image property holds the button text. + */ + ThumbnailButton: { + parent: "ButtonBase", + displayLabel: "Thumbnail list Button", + paletteImageName: "jqm_thumbnail_list_button.svg", + allowIn: [ "ThumbnailSplitListItem", "ThumbnailListItem" ], + properties: { + text: { + type: "string", + defaultValue: "ThumbnailSplit List Item" + }, + }, + template:'', + zones: [ + { + name: "left", + cardinality: "1", + allow: [ "Image" ] + }, + { + name: "right", + cardinality: "N", + allow: [ "Text" ] + } + ], + init: function (node) { + // initial state is three Image and Texts + var image = ADM.createNode("Image"); + var text = ADM.createNode("Text"); + text.setProperty("type", "h3"); + text.setProperty("text", "Thumbnail List Item"); + node.addChild(text); + text = ADM.createNode("Text"); + text.setProperty("type", "p"); + text.setProperty("text", "Thumbnail List Item"); + node.addChild(text); + node.addChild(image); + } + }, + + /** + * Represents a button. A Image property holds the button text. + */ + TextButton: { + parent: "ButtonBase", + displayLabel: "Text list Button", + paletteImageName: "jqm_text_list_button.svg", + allowIn: [ "TextListItem", "TextSplitListItem" ], + properties: { + text: { + type: "string", + defaultValue: "Text List Item" + }, + }, + template:'', + zones: [ + { + name: "right", + cardinality: "N", + allow: [ "Text" ] + } + ], + init: function (node) { + // initial state is three Image and Texts + var widgit; + widgit = ADM.createNode("Text"); + widgit.setProperty("type", "h3"); + widgit.setProperty("text", "Text List Item"); + node.addChild(widgit); + widgit = ADM.createNode("Text"); + widgit.setProperty("type", "p"); + widgit.setProperty("text", "Text List Item"); + node.addChild(widgit); + } }, /** From 5e1860d8c8028e637af134367021b88c972058c3 Mon Sep 17 00:00:00 2001 From: John Chen Date: Wed, 1 Aug 2012 11:55:53 +0800 Subject: [PATCH 05/26] [Widgets] Allow subtype to be treated as base type in type list checking --- src/js/widgets.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/js/widgets.js b/src/js/widgets.js index afa289c8..70bf245c 100644 --- a/src/js/widgets.js +++ b/src/js/widgets.js @@ -3154,15 +3154,23 @@ var BWidget = { // returns: true, if type is the list string, or type is one of the // strings in list // false, otherwise, or if list is invalid - var i; + var i, parentType = type, + isType = function (srcType, targetType) { + if (srcType === targetType) + return true; + while (srcType && (srcType = BWidgetRegistry[srcType].parent)) { + if (srcType === targetType) + return true; + } + return false; + }; if (list) { - if (type === list) { + if (isType(type, list)) { return true; } else if (list.length > 0) { for (i = list.length - 1; i >= 0; i--) { - if (type === list[i]) { + if (isType(type, list[i])) return true; - } } } } From 34e08124c3e332d35ca3430fce75621f787b1dba Mon Sep 17 00:00:00 2001 From: John Chen Date: Wed, 1 Aug 2012 12:19:43 +0800 Subject: [PATCH 06/26] [ADM] Support child type morphing We can define a "morph" function for a zone so that When adding a child, it can be morphed to another type. With this feature, we can have a generic widget in the palette which can adapt to different types of containers when dropped on them. --- src/js/adm.js | 11 ++++++++++- src/js/widgets.js | 7 ++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/js/adm.js b/src/js/adm.js index 364f82fa..379cd9d3 100644 --- a/src/js/adm.js +++ b/src/js/adm.js @@ -1666,11 +1666,20 @@ ADMNode.prototype.addChild = function (child, dryrun) { ADMNode.prototype.addChildToZone = function (child, zoneName, zoneIndex, dryrun) { // requires: assumes cardinality is "N", or a numeric string - var add = false, myType, childType, zone, cardinality, limit; + var add = false, myType, childType, zone, cardinality, limit, morph, morphedChildType; myType = this.getType(); childType = child.getType(); zone = this._zones[zoneName]; + morph = BWidget.getZone(myType, zoneName).morph; + if (morph) + { + morphedChildType = morph(childType, myType); + if (morphedChildType !== childType) { + childType = morphedChildType; + $.extend(true, child, ADM.createNode(morphedChildType)); + } + } if (!BWidget.zoneAllowsChild(myType, zoneName, childType)) { if (!dryrun) { console.warn("Warning: zone " + zoneName + diff --git a/src/js/widgets.js b/src/js/widgets.js index 70bf245c..3daf4911 100644 --- a/src/js/widgets.js +++ b/src/js/widgets.js @@ -159,6 +159,8 @@ var BCommonProperties = { * of this zone. * 6) itemWrapper: an HTML tag used to wrapp a child node before appending * to the zone + * 7) morph: function used to change the child type to another type before + * adding it to the zone * * The "properties" of each widget definition is an object, each property of * which names a property of the widget. These are objects with the following @@ -3219,7 +3221,7 @@ var BWidget = { * found. */ zoneAllowsChild: function (parentType, zone, childType) { - var parent, child, zones, i, allow, deny; + var parent, child, zones, i, allow, deny, morph; parent = BWidgetRegistry[parentType]; child = BWidgetRegistry[childType]; if ((typeof parent !== "object") || (typeof child !== "object")) { @@ -3230,6 +3232,9 @@ var BWidget = { if (zones && zones.length > 0) { for (i = zones.length - 1; i >= 0; i--) { if (zones[i].name === zone) { + morph = BWidget.getZone(parentType, zone).morph; + if (morph) + childType = morph(childType, parentType); allow = zones[i].allow; if (allow) { return BWidget.isTypeInList(childType, allow); From b93b4e02fbc1e1443e57dd1e3a09ffd082c05161 Mon Sep 17 00:00:00 2001 From: John Chen Date: Wed, 1 Aug 2012 21:27:37 +0800 Subject: [PATCH 07/26] [ADM] Add max and min limit of cardinality --- src/js/adm.js | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/js/adm.js b/src/js/adm.js index 379cd9d3..ac3801b1 100644 --- a/src/js/adm.js +++ b/src/js/adm.js @@ -1702,6 +1702,7 @@ ADMNode.prototype.addChildToZone = function (child, zoneName, zoneIndex, return false; } + cardinality = cardinality.max || cardinality; if (cardinality !== "N") { limit = parseInt(cardinality, 10); if (zone.length >= limit) { @@ -1913,12 +1914,30 @@ ADMNode.prototype.removeChild = function (child, dryrun) { * @return {ADMNode} The removed child, or null if not found. */ ADMNode.prototype.removeChildFromZone = function (zoneName, index, dryrun) { - var zone, removed, child, parentNode, parent; + var zone, removed, child, parent, cardinality, min; zone = this._zones[zoneName]; if (!zone) { console.error("Error: no such zone found while removing child: " + zoneName); } + cardinality = BWidget.getZoneCardinality(this.getType(), zoneName); + if (!cardinality) { + console.warn("Warning: no cardinality found for zone " + zoneName); + return false; + } + + if (cardinality.min) { + min = parseInt(cardinality.min, 10); + + if (zone.length <= min) { + alert("At least " + + cardinality.min + " " + + BWidget.getDisplayLabel(zone[index].getType()) + + (min === 1 ? " " : "s ") + + (min === 1 ? "is": "are") + " required and cannot be deleted!"); + return false; + } + } if (dryrun) { removed = [zone[index]]; From 79abc1ca593aef262cab6afb3c069d27e1c9fa3b Mon Sep 17 00:00:00 2001 From: John Chen Date: Fri, 3 Aug 2012 14:58:30 +0800 Subject: [PATCH 08/26] [Widgets] Extend zones more gracefully Looking for parent zone with the same name. If found, extend it with descendant zone, otherwize add a new zone. --- index.html | 2 +- src/js/widgets.js | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index 16382dc8..4d15006a 100644 --- a/index.html +++ b/index.html @@ -25,6 +25,7 @@ + @@ -34,7 +35,6 @@ - diff --git a/src/js/widgets.js b/src/js/widgets.js index 3daf4911..c2a95981 100644 --- a/src/js/widgets.js +++ b/src/js/widgets.js @@ -2416,7 +2416,7 @@ var BWidget = { init: function () { // effects: add the type and displayLabel properties to widget // registry objects - var type, parentName; + var type, parentName, newZones, descendantZone, descendantZoneIndex; for (type in BWidgetRegistry) { if (BWidgetRegistry.hasOwnProperty(type)) { BWidgetRegistry[type].type = type; @@ -2454,6 +2454,26 @@ var BWidget = { } parentName = BWidgetRegistry[type].parent; while (parentName) { + if (BWidgetRegistry[parentName].zones) { + newZones = []; + $.each(BWidgetRegistry[parentName].zones, function (i, pZone) { + descendantZone = null; + if (BWidgetRegistry[type].zones) + $.each(BWidgetRegistry[type].zones, function (i, zone) { + if (pZone.name === zone.name) { + descendantZone = zone; + descendantZoneIndex = i; + return false; + } + }); + if (descendantZone) + BWidgetRegistry[type].zones[descendantZoneIndex] = $.extend(true, true, {}, pZone, descendantZone); + else + newZones.push(pZone); + }); + if(BWidgetRegistry[type].zones) + $.merge(BWidgetRegistry[type].zones, newZones); + } BWidgetRegistry[type] = $.extend(true, true, {}, BWidgetRegistry[parentName], BWidgetRegistry[type]); parentName = BWidgetRegistry[parentName].parent; } From 6138fe53628323c60345dcf1efe744ea381df41b Mon Sep 17 00:00:00 2001 From: John Chen Date: Mon, 6 Aug 2012 15:35:28 +0800 Subject: [PATCH 09/26] [Widgets] Enable using function as a zone's "allow" field --- src/js/widgets.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/js/widgets.js b/src/js/widgets.js index c2a95981..0ec5825b 100644 --- a/src/js/widgets.js +++ b/src/js/widgets.js @@ -150,7 +150,8 @@ var BCommonProperties = { * Each zone description in the array should be an object with: * 1) name identifying the zone point * 2) cardinality, either "1" or "N" representing number of contained items - * 3) allow: string or array of string names of allowable widgets + * 3) allow: string or array of string names or a function that returns + * a string or an array of allowable widgets * (all others will be denied) * 4) deny: string or array of string names of disallowed widgets * (all others will be allowed) @@ -3257,6 +3258,8 @@ var BWidget = { childType = morph(childType, parentType); allow = zones[i].allow; if (allow) { + if (typeof allow === "function") + allow = allow(parentType); return BWidget.isTypeInList(childType, allow); } deny = zones[i].deny; From ec0f7fcbfa235d0b8d7cdbe679881e4dfaf67bae Mon Sep 17 00:00:00 2001 From: yongfeng wu Date: Tue, 31 Jul 2012 16:01:02 +0800 Subject: [PATCH 10/26] [Widgets] Implement list widgets using generic item and button --- src/assets/groups.json | 28 +++---- src/css/images/widgets/jqm_list_item.svg | 2 +- src/js/widgets.js | 93 +++++++++--------------- 3 files changed, 49 insertions(+), 74 deletions(-) diff --git a/src/assets/groups.json b/src/assets/groups.json index 90c81f47..507a5032 100644 --- a/src/assets/groups.json +++ b/src/assets/groups.json @@ -24,20 +24,22 @@ "List Views": [ { "Ordered List": ["OrderedList", "SimpleListItem", "ListDivider"], "Unordered Lists": [ { - "Single Lists": [ { - "Simple Single List": ["SimpleList", "SimpleListItem", "ListDivider"], - "Button Single List": ["ButtonList", "ButtonListItem", "ListButton", "ListDivider"], - "Text Single List": ["TextList", "TextListItem", "ListDivider", "TextButton"], - "Icon Single List": ["IconList", "IconListItem", "IconButton", "ListDivider"], - "Thumbnail Single List": ["ThumbnailList", "ThumbnailListItem", "ThumbnailButton", "ListDivider"] - } + "Single Lists": [ + "SimpleList", + "ButtonList", + "TextList", + "IconList", + "ThumbnailList", + "SimpleListItem", + "ListDivider" ], - "Split Lists": [ { - "Simple Split List": ["SimpleSplitList", "SimpleSplitListItem"], - "Text Split List": ["TextSplitList", "TextSplitListItem", "TextButton"], - "Icon Split List": ["IconSplitList", "IconSplitListItem", "IconButton"], - "Thumbnail Split List": ["ThumbnailSplitList", "ThumbnailSplitListItem", "ThumbnailButton"] - } + "Split Lists": [ + "SimpleSplitList", + "TextSplitList", + "IconSplitList", + "ThumbnailSplitList", + "SimpleListItem", + "ListDivider" ] } ] diff --git a/src/css/images/widgets/jqm_list_item.svg b/src/css/images/widgets/jqm_list_item.svg index 00d56daa..7703f1a0 100644 --- a/src/css/images/widgets/jqm_list_item.svg +++ b/src/css/images/widgets/jqm_list_item.svg @@ -24,5 +24,5 @@ -Simple List Item +List Item diff --git a/src/js/widgets.js b/src/js/widgets.js index 0ec5825b..82f0cbec 100644 --- a/src/js/widgets.js +++ b/src/js/widgets.js @@ -1404,11 +1404,6 @@ var BWidgetRegistry = { ButtonList: { parent: "SimpleList", paletteImageName: "jqm_button_list.svg", - zones: [ - { - allow: [ "ButtonListItem"] - } - ] }, /** @@ -1417,11 +1412,6 @@ var BWidgetRegistry = { TextList: { parent: "SimpleList", paletteImageName: "jqm_text_list.svg", - zones: [ - { - allow: [ "TextListItem" ] - } - ] }, /** @@ -1431,11 +1421,6 @@ var BWidgetRegistry = { parent: "SimpleList", paletteImageName: "jqm_icon_list.svg", template: '
                  ', - zones: [ - { - allow: [ "IconListItem" ] - } - ] }, /** @@ -1445,11 +1430,6 @@ var BWidgetRegistry = { parent: "SimpleList", paletteImageName: "jqm_thumbnail_list.svg", template: '
                    ', - zones: [ - { - allow: [ "ThumbnailListItem" ] - } - ] }, /** * Represents a base List widget @@ -1466,11 +1446,28 @@ var BWidgetRegistry = { htmlAttribute: "data-divider-theme" }) }, + getItemType: function (listType) { + if (listType !== "OrderedList") + return listType + "Item"; + else + return "SimpleListItem"; + }, zones: [ { name: "default", cardinality: "N", - allow: [ "SimpleListItem", "ListDivider" ] + morph: function (childType, thisType) { + if (childType === "SimpleListItem") { + if (thisType === "OrderedList") + return "SimpleListItem"; + else + return thisType + "Item"; + } + return childType; + }, + allow: function (type) { + return [ BWidgetRegistry.ListBase.getItemType(type), "ListDivider" ]; + } } ], delegate: function (domNode, admNode) { @@ -1516,13 +1513,6 @@ var BWidgetRegistry = { ThumbnailSplitList: { parent: "SimpleSplitList", paletteImageName: "jqm_thumbnail_split_list.svg", - zones: [ - { - name: "default", - cardinality: "N", - allow: [ "ThumbnailSplitListItem"] - } - ], }, /** @@ -1550,11 +1540,6 @@ var BWidgetRegistry = { } }, template: '
                      ', - zones: [ - { - allow: [ "SimpleSplitListItem"] - } - ] }, /** @@ -1563,11 +1548,6 @@ var BWidgetRegistry = { TextSplitList: { parent: "SimpleSplitList", paletteImageName: "jqm_text_split_list.svg", - zones: [ - { - allow: [ "TextSplitListItem"] - } - ] }, /** @@ -1576,21 +1556,16 @@ var BWidgetRegistry = { IconSplitList: { parent: "SimpleSplitList", paletteImageName: "jqm_icon_split_list.svg", - zones: [ - { - allow: [ "IconSplitListItem"] - } - ] }, /** - * Represents a list item element. + * Represents a generic list item element. */ SimpleListItem: { parent: "Base", - displayLabel: "Simple List Item", + displayLabel: "List Item", paletteImageName: "jqm_list_item.svg", - allowIn: [ "SimpleList", "OrderedList" ], + allowIn: [ "ListBase" ], editable: { selector: "", propertyName: "text" @@ -1622,7 +1597,7 @@ var BWidgetRegistry = { zones: [ { name: "default", - cardinality: "1", + cardinality: { min: "1", max: "1"}, allow: [ "ListButton" ] } ], @@ -1642,6 +1617,7 @@ var BWidgetRegistry = { template: '
                    • ', zones: [ { + name: "default", allow: [ "TextButton" ] }, ], @@ -1662,6 +1638,7 @@ var BWidgetRegistry = { template: '
                    • ', zones: [ { + name: "default", allow: [ "IconButton" ] } ], @@ -1682,6 +1659,7 @@ var BWidgetRegistry = { template: '
                    • ', zones: [ { + name: "default", allow: [ "ThumbnailButton" ] } ], @@ -1702,14 +1680,8 @@ var BWidgetRegistry = { zones: [ { name: "left", - cardinality: "1", allow: [ "ThumbnailButton" ] }, - { - name: "right", - cardinality: "1", - allow: [ "ListButton" ] - } ], init: function (node) { // initial state is three buttons @@ -1722,7 +1694,7 @@ var BWidgetRegistry = { * Represents a SplitListItem element. */ SimpleSplitListItem: { - parent: "ButtonListItem", + parent: "SimpleListItem", displayLabel: "Simple Split List Item", paletteImageName: "jqm_simple_split_list_item.svg", allowIn: [ "SimpleSplitList" ], @@ -1735,7 +1707,12 @@ var BWidgetRegistry = { zones: [ { name: "left", - cardinality: "2", + cardinality: {min: "1", max: "1"}, + allow: [ "ListButton" ] + }, + { + name: "right", + cardinality: {min: "1", max: "1"}, allow: [ "ListButton" ] } ], @@ -1757,12 +1734,10 @@ var BWidgetRegistry = { zones: [ { name: "left", - cardinality: "1", allow: [ "IconButton" ] }, { name: "right", - cardinality: "1", allow: [ "ListButton" ] } ], @@ -1784,12 +1759,10 @@ var BWidgetRegistry = { zones: [ { name: "left", - cardinality: "1", allow: [ "TextButton" ] }, { name: "right", - cardinality: "1", allow: [ "ListButton" ] } ], @@ -1807,7 +1780,7 @@ var BWidgetRegistry = { parent: "SimpleListItem", displayLabel: "List Divider", paletteImageName: "jqm_list_divider.svg", - allowIn: [ "SimpleList", "OrderedList", "ButtonList", "TextList", "IconList", "ThumbnailList" ], + allowIn: [ "ListBase" ], properties: { text: { defaultValue: "List Divider" From 1ee93f1ceeb610503ba1c0cd74e0f764092489b3 Mon Sep 17 00:00:00 2001 From: John Chen Date: Tue, 7 Aug 2012 11:50:37 +0800 Subject: [PATCH 11/26] [Widgets] Implement ordered list as a property of ListBase --- src/assets/groups.json | 4 ---- src/js/widgets.js | 23 ++++++++++------------- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/src/assets/groups.json b/src/assets/groups.json index 507a5032..c29fd3e0 100644 --- a/src/assets/groups.json +++ b/src/assets/groups.json @@ -22,8 +22,6 @@ } ], "List Views": [ { - "Ordered List": ["OrderedList", "SimpleListItem", "ListDivider"], - "Unordered Lists": [ { "Single Lists": [ "SimpleList", "ButtonList", @@ -41,8 +39,6 @@ "SimpleListItem", "ListDivider" ] - } - ] } ], "Image": ["Image"] diff --git a/src/js/widgets.js b/src/js/widgets.js index 82f0cbec..d7a21415 100644 --- a/src/js/widgets.js +++ b/src/js/widgets.js @@ -1395,7 +1395,6 @@ var BWidgetRegistry = { htmlAttribute: "data-filter-placeholder" } }, - template: '
                        ', }, /** @@ -1420,7 +1419,6 @@ var BWidgetRegistry = { IconList: { parent: "SimpleList", paletteImageName: "jqm_icon_list.svg", - template: '
                          ', }, /** @@ -1429,7 +1427,6 @@ var BWidgetRegistry = { ThumbnailList: { parent: "SimpleList", paletteImageName: "jqm_thumbnail_list.svg", - template: '
                            ', }, /** * Represents a base List widget @@ -1441,6 +1438,10 @@ var BWidgetRegistry = { inset: BCommonProperties.inset, filter: BCommonProperties.filter, theme: BCommonProperties.theme, + ordered: { + type: "boolean", + defaultValue: false, + }, divider_theme: $.extend({}, BCommonProperties.theme, { displayName: "divider theme", htmlAttribute: "data-divider-theme" @@ -1486,6 +1487,12 @@ var BWidgetRegistry = { // Reconstruct the domNode. return filterForm.wrap(newNode).parent().append(domNode); }, + template: function (node) { + if (node.getProperty("ordered")) + return $('
                              '); + else + return $('
                                '); + }, init: function (node) { // initial state is three button ListItem var i; @@ -1498,15 +1505,6 @@ var BWidgetRegistry = { } }, - /** - * Represents an ordered list element. - */ - OrderedList: { - parent: "ListBase", - paletteImageName: "jqm_ordered_list.svg", - template: '
                                  ', - }, - /** * Represents a Split list element. */ @@ -1539,7 +1537,6 @@ var BWidgetRegistry = { htmlAttribute: "data-split-icon" } }, - template: '
                                    ', }, /** From fd73d0de5792b3d1a02adaa551347f602bb89d2f Mon Sep 17 00:00:00 2001 From: John Chen Date: Tue, 7 Aug 2012 14:21:49 +0800 Subject: [PATCH 12/26] [Widgets] Change name of SimpleSplitList to ButtonSplitList --- src/assets/groups.json | 2 +- ...lit_list.svg => jqm_button_split_list.svg} | Bin 4042 -> 4042 bytes ...tem.svg => jqm_button_split_list_item.svg} | Bin 2464 -> 2464 bytes src/js/widgets.js | 28 +++++++++--------- 4 files changed, 15 insertions(+), 15 deletions(-) rename src/css/images/widgets/{jqm_simple_split_list.svg => jqm_button_split_list.svg} (96%) rename src/css/images/widgets/{jqm_simple_split_list_item.svg => jqm_button_split_list_item.svg} (95%) diff --git a/src/assets/groups.json b/src/assets/groups.json index c29fd3e0..202514fa 100644 --- a/src/assets/groups.json +++ b/src/assets/groups.json @@ -32,7 +32,7 @@ "ListDivider" ], "Split Lists": [ - "SimpleSplitList", + "ButtonSplitList", "TextSplitList", "IconSplitList", "ThumbnailSplitList", diff --git a/src/css/images/widgets/jqm_simple_split_list.svg b/src/css/images/widgets/jqm_button_split_list.svg similarity index 96% rename from src/css/images/widgets/jqm_simple_split_list.svg rename to src/css/images/widgets/jqm_button_split_list.svg index 1542ca00d31cb6be251f3c765a1f62d6c6855d92..edd6c5ce5c304a8413ebdcacbe164acfd88ff113 100644 GIT binary patch delta 40 mcmX>le@cFX2M>1=Ln%WE5au)FO%CQ!=XOHyH@EV*G6MkWg9@qu delta 40 ncmX>le@cFX2M>2KLncEmLjgk$L+a#U9(C?u1b=fYk1I0(=${IP diff --git a/src/css/images/widgets/jqm_simple_split_list_item.svg b/src/css/images/widgets/jqm_button_split_list_item.svg similarity index 95% rename from src/css/images/widgets/jqm_simple_split_list_item.svg rename to src/css/images/widgets/jqm_button_split_list_item.svg index d3304a98acc6cbe53ff90d56e320bbcc28977284..1a0b781c3df3d82607c47374831d25c468a794d1 100644 GIT binary patch delta 39 kcmZ1=yg+z^5+`>OLn%WE5au)FP1fZ!hXL6bY0LL^5rT_o{ delta 39 lcmZ1=yg+z^5+`>tLncEmLjgk$L+WH*PDAcsBz`8RIRM3U34#Cs diff --git a/src/js/widgets.js b/src/js/widgets.js index d7a21415..e25de3db 100644 --- a/src/js/widgets.js +++ b/src/js/widgets.js @@ -1509,16 +1509,16 @@ var BWidgetRegistry = { * Represents a Split list element. */ ThumbnailSplitList: { - parent: "SimpleSplitList", + parent: "ButtonSplitList", paletteImageName: "jqm_thumbnail_split_list.svg", }, /** * Represents a Split list element. */ - SimpleSplitList: { + ButtonSplitList: { parent: "ListBase", - paletteImageName: "jqm_simple_split_list.svg", + paletteImageName: "jqm_button_split_list.svg", properties: { theme: { type: "string", @@ -1543,7 +1543,7 @@ var BWidgetRegistry = { * Represents a Split list element. */ TextSplitList: { - parent: "SimpleSplitList", + parent: "ButtonSplitList", paletteImageName: "jqm_text_split_list.svg", }, @@ -1551,7 +1551,7 @@ var BWidgetRegistry = { * Represents a Split list element. */ IconSplitList: { - parent: "SimpleSplitList", + parent: "ButtonSplitList", paletteImageName: "jqm_icon_split_list.svg", }, @@ -1670,7 +1670,7 @@ var BWidgetRegistry = { * Represents a SplitListItem element. */ ThumbnailSplitListItem: { - parent: "SimpleSplitListItem", + parent: "ButtonSplitListItem", displayLabel: "Thumbnail Split List Item", paletteImageName: "jqm_thumbnail_split_list_item.svg", allowIn: [ "ThumbnailSplitList" ], @@ -1690,11 +1690,11 @@ var BWidgetRegistry = { /** * Represents a SplitListItem element. */ - SimpleSplitListItem: { + ButtonSplitListItem: { parent: "SimpleListItem", - displayLabel: "Simple Split List Item", - paletteImageName: "jqm_simple_split_list_item.svg", - allowIn: [ "SimpleSplitList" ], + displayLabel: "Button Split List Item", + paletteImageName: "jqm_button_split_list_item.svg", + allowIn: [ "ButtonSplitList" ], properties: { text: { defaultValue: "List Item", @@ -1724,7 +1724,7 @@ var BWidgetRegistry = { * Represents a SplitListItem element. */ IconSplitListItem: { - parent: "SimpleSplitListItem", + parent: "ButtonSplitListItem", displayLabel: "Icon Split List Item", paletteImageName: "jqm_icon_split_list_item.svg", allowIn: [ "IconSplitList" ], @@ -1749,7 +1749,7 @@ var BWidgetRegistry = { * Represents a SplitListItem element. */ TextSplitListItem: { - parent: "SimpleSplitListItem", + parent: "ButtonSplitListItem", displayLabel: "Text Split List Item", paletteImageName: "jqm_text_split_list_item.svg", allowIn: [ "TextSplitList" ], @@ -1791,9 +1791,9 @@ var BWidgetRegistry = { */ ListButton: { parent: "ButtonBase", - displayLabel: "List Button", + displayLabel: "Extra Button", paletteImageName: "jqm_list_button.svg", - allowIn: [ "ButtonListItem", "ThumbnailSplitListItem", "SimpleSplitListItem", "TextSplitListItem", "IconSplitListItem" ], + allowIn: [ "ButtonListItem", "ThumbnailSplitListItem", "ButtonSplitListItem", "TextSplitListItem", "IconSplitListItem" ], properties: { text: { defaultValue: "List Button" From cfe0f2347215cf52d8ec7b0a9568407112c7ab6d Mon Sep 17 00:00:00 2001 From: John Chen Date: Tue, 7 Aug 2012 16:57:23 +0800 Subject: [PATCH 13/26] [Widgets] Introduce default htmlSelector --- src/js/widgets.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/js/widgets.js b/src/js/widgets.js index e25de3db..24877a9c 100644 --- a/src/js/widgets.js +++ b/src/js/widgets.js @@ -2842,7 +2842,8 @@ var BWidget = { getPropertyHTMLSelector: function (widgetType, property) { var schema = BWidget.getPropertySchema(widgetType, property); if (schema) { - return schema.htmlSelector; + return schema.htmlSelector !== undefined ? schema.htmlSelector : + BWidget.getWidgetAttribute(widgetType, "defaultHtmlSelector"); } return schema; }, From 9ab5d9fc4527726e3272d6223e75e9028b81611d Mon Sep 17 00:00:00 2001 From: John Chen Date: Tue, 7 Aug 2012 16:59:50 +0800 Subject: [PATCH 14/26] [Widgets] Extract text property to BCommonProperties --- src/js/widgets.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/js/widgets.js b/src/js/widgets.js index 24877a9c..3b13889c 100644 --- a/src/js/widgets.js +++ b/src/js/widgets.js @@ -69,6 +69,10 @@ var BCommonProperties = { defaultValue: "default", htmlAttribute: "data-position" }, + text: { + type: "string", + defaultValue: "Button" + }, theme: { type: "string", options: function() { From 5d3c25649a5a2e1eaf4f2694859039bc93865214 Mon Sep 17 00:00:00 2001 From: John Chen Date: Tue, 7 Aug 2012 14:28:28 +0800 Subject: [PATCH 15/26] [Widgets] Collapse split list button into SplitListItem --- src/js/widgets.js | 163 ++++++++++++++++++++++++++++++---------------- 1 file changed, 108 insertions(+), 55 deletions(-) diff --git a/src/js/widgets.js b/src/js/widgets.js index 3b13889c..886ec1dc 100644 --- a/src/js/widgets.js +++ b/src/js/widgets.js @@ -673,21 +673,7 @@ var BWidgetRegistry = { */ ButtonBase: { parent: "Base", - editable: { - selector: "span > .ui-btn-text", - propertyName: "text" - }, properties: { - text: { - type: "string", - defaultValue: "Button" - }, - right: { - displayName: "align right", - validIn: "Header", - type: "boolean", - defaultValue: false - }, target: { type: "targetlist", defaultValue: "", @@ -723,7 +709,18 @@ var BWidgetRegistry = { Button: { parent: "ButtonBase", paletteImageName: "jqm_button.svg", + editable: { + selector: "span > .ui-btn-text", + propertyName: "text" + }, properties: { + text: BCommonProperties.text, + right: { + displayName: "align right", + validIn: "Header", + type: "boolean", + defaultValue: false + }, icon: BCommonProperties.icon, iconpos: $.extend({}, BCommonProperties.iconpos, { invalidIn: "Navbar" @@ -1674,19 +1671,37 @@ var BWidgetRegistry = { * Represents a SplitListItem element. */ ThumbnailSplitListItem: { - parent: "ButtonSplitListItem", + parent: "SplitListItemBase", displayLabel: "Thumbnail Split List Item", paletteImageName: "jqm_thumbnail_split_list_item.svg", allowIn: [ "ThumbnailSplitList" ], zones: [ { name: "left", - allow: [ "ThumbnailButton" ] + cardinality: "1", + locator: "a", + allow: [ "Image" ] }, + { + name: "right", + cardinality: "N", + locator: "a", + allow: [ "Text" ] + } ], init: function (node) { - // initial state is three buttons - node.addChild(ADM.createNode("ThumbnailButton")); + // initial state is three Image and Texts + var image = ADM.createNode("Image"); + var text = ADM.createNode("Text"); + text.setProperty("type", "h3"); + text.setProperty("text", "Thumbnail List Item"); + node.addChild(text); + text = ADM.createNode("Text"); + text.setProperty("type", "p"); + text.setProperty("text", "Thumbnail List Item"); + node.addChild(text); + node.addChild(image); + node.addChild(ADM.createNode("ListButton")); } }, @@ -1694,36 +1709,46 @@ var BWidgetRegistry = { /** * Represents a SplitListItem element. */ - ButtonSplitListItem: { - parent: "SimpleListItem", - displayLabel: "Button Split List Item", - paletteImageName: "jqm_button_split_list_item.svg", - allowIn: [ "ButtonSplitList" ], + SplitListItemBase: { + parent: "ButtonBase", + defaultHtmlSelector: "a", properties: { - text: { - defaultValue: "List Item", - }, + theme: $.extend(true, {}, BCommonProperties.theme, { + htmlSelector: "" + }) }, - template: '
                                  • ', + template: '
                                  • ', zones: [ { - name: "left", + name: "extra", cardinality: {min: "1", max: "1"}, allow: [ "ListButton" ] }, - { - name: "right", - cardinality: {min: "1", max: "1"}, - allow: [ "ListButton" ] - } ], init: function (node) { // initial state is three buttons node.addChild(ADM.createNode("ListButton")); - node.addChild(ADM.createNode("ListButton")); } }, + /** + * Represents a SplitListItem element. + */ + ButtonSplitListItem: { + parent: "SplitListItemBase", + displayLabel: "Button Split List Item", + paletteImageName: "jqm_button_split_list_item.svg", + allowIn: [ "ButtonSplitList" ], + template: '
                                  • %TEXT%
                                  • ', + editable: { + selector: ".ui-btn-text > a", + propertyName: "text" + }, + properties: { + text: BCommonProperties.text, + }, + }, + /** * Represents a SplitListItem element. */ @@ -1732,20 +1757,42 @@ var BWidgetRegistry = { displayLabel: "Icon Split List Item", paletteImageName: "jqm_icon_split_list_item.svg", allowIn: [ "IconSplitList" ], - zones: [ - { - name: "left", - allow: [ "IconButton" ] + properties: { + text: { + defaultValue: "Icon List Item" }, - { - name: "right", - allow: [ "ListButton" ] + iconsrc: { + type: "url-uploadable", + defaultValue: "src/css/images/widgets/tizen_image.svg", + htmlSelector: "img", + htmlAttribute: "src", + forceAttribute: true + }, + countbubble: { + type: "string", + displayName: "count bubble", + defaultValue: "0" } - ], - init: function (node) { - // initial state is three buttons - node.addChild(ADM.createNode("IconButton")); - node.addChild(ADM.createNode("ListButton")); + }, + template: function(node) { + var prop, iconsrc, countBubble, code = $('
                                  • %TEXT%
                                  • '); + prop = node.getProperty("countbubble"); + // Add the count bubble if countbubble property is not blank + if (prop.trim() != '') { + countBubble = $('') + .attr('class', 'ui-li-count') + .html(prop); + code.find('a').append(countBubble); + }; + prop = node.getProperty("iconsrc"); + // Add the count bubble if iconsrc property is not blank + if (prop.trim() != '') { + iconsrc = $('') + .attr('width','16') + .attr('class', 'ui-li-icon'); + code.find('a').append(iconsrc); + }; + return code; } }, @@ -1753,23 +1800,29 @@ var BWidgetRegistry = { * Represents a SplitListItem element. */ TextSplitListItem: { - parent: "ButtonSplitListItem", + parent: "SplitListItemBase", displayLabel: "Text Split List Item", paletteImageName: "jqm_text_split_list_item.svg", allowIn: [ "TextSplitList" ], zones: [ { - name: "left", - allow: [ "TextButton" ] - }, - { - name: "right", - allow: [ "ListButton" ] + name: "default", + cardinality: "N", + locator: "a", + allow: [ "Text" ] } ], init: function (node) { // initial state is three buttons - node.addChild(ADM.createNode("TextButton")); + var widgit; + widgit = ADM.createNode("Text"); + widgit.setProperty("type", "h3"); + widgit.setProperty("text", "Text List Item"); + node.addChild(widgit); + widgit = ADM.createNode("Text"); + widgit.setProperty("type", "p"); + widgit.setProperty("text", "Text List Item"); + node.addChild(widgit); node.addChild(ADM.createNode("ListButton")); } }, @@ -1797,7 +1850,7 @@ var BWidgetRegistry = { parent: "ButtonBase", displayLabel: "Extra Button", paletteImageName: "jqm_list_button.svg", - allowIn: [ "ButtonListItem", "ThumbnailSplitListItem", "ButtonSplitListItem", "TextSplitListItem", "IconSplitListItem" ], + allowIn: [ "SplitListItemBase"], properties: { text: { defaultValue: "List Button" From b7fe4865f767e1062e9c5e123c741df5f14ad414 Mon Sep 17 00:00:00 2001 From: yongfeng wu Date: Wed, 8 Aug 2012 14:26:36 +0800 Subject: [PATCH 16/26] [Widgets] Collapse list button into ListItem --- src/js/widgets.js | 158 ++++++++++++++++++++++++++++------------------ 1 file changed, 98 insertions(+), 60 deletions(-) diff --git a/src/js/widgets.js b/src/js/widgets.js index 886ec1dc..7b46b71e 100644 --- a/src/js/widgets.js +++ b/src/js/widgets.js @@ -1571,7 +1571,7 @@ var BWidgetRegistry = { properties: { text: { type: "string", - defaultValue: "", + defaultValue: "List Item", }, theme: BCommonProperties.theme, filtertext: { @@ -1584,44 +1584,68 @@ var BWidgetRegistry = { template: '
                                  • %TEXT%
                                  • ' }, + /** + * Represents a ListItem element. + */ + ListItemBase: { + parent: "ButtonBase", + defaultHtmlSelector: "a", + properties: { + theme: $.extend(true, {}, BCommonProperties.theme, { + htmlSelector: "" + }) + }, + template: '
                                  • ' + }, + /** * Represents a list button item element. */ ButtonListItem: { - parent: "SimpleListItem", + parent: "ListItemBase", displayLabel: "Button List Item", paletteImageName: "jqm_button_list_item.svg", allowIn: [ "ButtonList" ], - zones: [ - { - name: "default", - cardinality: { min: "1", max: "1"}, - allow: [ "ListButton" ] + editable: { + selector: ".ui-btn-text > a", + propertyName: "text" + }, + properties: { + text: { + type: "string", + defaultValue: "Button List Item", } - ], - init: function (node) { - node.addChild(ADM.createNode("ListButton")); - } + }, + template: '
                                  • %TEXT%
                                  • ', }, /** * Represents a list text item element. */ TextListItem: { - parent: "ButtonListItem", + parent: "ListItemBase", displayLabel: "Text List Item", paletteImageName: "jqm_text_list_item.svg", allowIn: [ "TextList" ], - template: '
                                  • ', zones: [ { name: "default", - allow: [ "TextButton" ] + cardinality: "N", + locator: "a", + allow: [ "Text" ] }, ], init: function (node) { // initial state is three TextButton - node.addChild(ADM.createNode("TextButton")); + var widgit; + widgit = ADM.createNode("Text"); + widgit.setProperty("type", "h3"); + widgit.setProperty("text", "Text List Item"); + node.addChild(widgit); + widgit = ADM.createNode("Text"); + widgit.setProperty("type", "p"); + widgit.setProperty("text", "Text List Item"); + node.addChild(widgit); } }, @@ -1633,16 +1657,42 @@ var BWidgetRegistry = { displayLabel: "Icon List Item", paletteImageName: "jqm_icon_list_item.svg", allowIn: [ "IconList" ], - template: '
                                  • ', - zones: [ - { - name: "default", - allow: [ "IconButton" ] + properties: { + text: { + defaultValue: "Icon List Item" + }, + iconsrc: { + type: "url-uploadable", + defaultValue: "src/css/images/widgets/tizen_image.svg", + htmlSelector: "img", + htmlAttribute: "src", + forceAttribute: true + }, + countbubble: { + type: "string", + displayName: "count bubble", + defaultValue: "0" } - ], - init: function (node) { - // initial state is three buttons - node.addChild(ADM.createNode("IconButton")); + }, + template: function(node) { + var prop, iconsrc, countBubble, code = $('
                                  • %TEXT%
                                  • '); + prop = node.getProperty("countbubble"); + // Add the count bubble if countbubble property is not blank + if (prop.trim() != '') { + countBubble = $('') + .attr('class', 'ui-li-count') + .html(prop); + code.find('a').append(countBubble); + }; + prop = node.getProperty("iconsrc"); + // Add the count bubble if iconsrc property is not blank + if (prop.trim() != '') { + iconsrc = $('') + .attr('width','16') + .attr('class', 'ui-li-icon'); + code.find('a').append(iconsrc); + }; + return code; } }, @@ -1650,20 +1700,36 @@ var BWidgetRegistry = { * Represents a ThumbnailListItem element. */ ThumbnailListItem: { - parent: "ButtonListItem", + parent: "ListItemBase", displayLabel: "Thumbnail List Item", paletteImageName: "jqm_thumbnail_list_item.svg", allowIn: [ "ThumbnailList"], - template: '
                                  • ', zones: [ { - name: "default", - allow: [ "ThumbnailButton" ] + name: "left", + cardinality: "1", + locator: "a", + allow: [ "Image" ] + }, + { + name: "right", + cardinality: "N", + locator: "a", + allow: [ "Text" ] } ], init: function (node) { // initial state is a ThumbnailButton - node.addChild(ADM.createNode("ThumbnailButton")); + var image = ADM.createNode("Image"); + var text = ADM.createNode("Text"); + text.setProperty("type", "h3"); + text.setProperty("text", "Thumbnail List Item"); + node.addChild(text); + text = ADM.createNode("Text"); + text.setProperty("type", "p"); + text.setProperty("text", "Thumbnail List Item"); + node.addChild(text); + node.addChild(image); } }, @@ -1710,14 +1776,7 @@ var BWidgetRegistry = { * Represents a SplitListItem element. */ SplitListItemBase: { - parent: "ButtonBase", - defaultHtmlSelector: "a", - properties: { - theme: $.extend(true, {}, BCommonProperties.theme, { - htmlSelector: "" - }) - }, - template: '
                                  • ', + parent: "ListItemBase", zones: [ { name: "extra", @@ -1741,7 +1800,7 @@ var BWidgetRegistry = { allowIn: [ "ButtonSplitList" ], template: '
                                  • %TEXT%
                                  • ', editable: { - selector: ".ui-btn-text > a", + selector: "", propertyName: "text" }, properties: { @@ -1852,34 +1911,13 @@ var BWidgetRegistry = { paletteImageName: "jqm_list_button.svg", allowIn: [ "SplitListItemBase"], properties: { - text: { - defaultValue: "List Button" - }, icon: $.extend({}, BCommonProperties.icon, { options: BCommonProperties.icon.options.slice(1), defaultValue: "arrow-r" }), theme: BCommonProperties.theme, - countbubble: { - type: "string", - displayName: "count bubble", - defaultValue: "" - } }, - template: function (node) { - var prop, countBubble, code = $('%TEXT%<'); - - prop = node.getProperty("countbubble"); - // Add the count bubble if countbubble property is not blank - if (prop.trim() != '') { - countBubble = $('') - .attr('class', 'ui-li-count') - .html(prop); - code.append(countBubble); - }; - - return code; - } + template: '', }, /** From f80900ba26176ca773bc5a4adcdd4aef40afe2e8 Mon Sep 17 00:00:00 2001 From: John Chen Date: Wed, 8 Aug 2012 16:20:23 +0800 Subject: [PATCH 17/26] [Widgets] Introduce multiple inheritance --- src/js/adm.js | 14 ++------------ src/js/widgets.js | 28 ++++++++++++++++++---------- 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/src/js/adm.js b/src/js/adm.js index ac3801b1..9812fb39 100644 --- a/src/js/adm.js +++ b/src/js/adm.js @@ -1167,18 +1167,8 @@ function ADMNode(widgetType) { var currentType = widgetType, widget, zones, length, i, func; this._valid = false; - this._inheritance = []; - - while (currentType) { - widget = BWidgetRegistry[currentType]; - if (typeof widget === "object") { - this._inheritance.push(currentType); - currentType = widget.parent; - } else { - console.error("Error: invalid type hierarchy creating ADM node"); - return; - } - } + this._inheritance = [widgetType]; + $.merge(this._inheritance, BWidget.getAncestors(widgetType)); this._uid = ++ADMNode.prototype._lastUid; diff --git a/src/js/widgets.js b/src/js/widgets.js index 7b46b71e..38df6deb 100644 --- a/src/js/widgets.js +++ b/src/js/widgets.js @@ -2482,7 +2482,7 @@ var BWidget = { init: function () { // effects: add the type and displayLabel properties to widget // registry objects - var type, parentName, newZones, descendantZone, descendantZoneIndex; + var type, newZones, descendantZone, descendantZoneIndex; for (type in BWidgetRegistry) { if (BWidgetRegistry.hasOwnProperty(type)) { BWidgetRegistry[type].type = type; @@ -2518,8 +2518,7 @@ var BWidget = { if (type === "OptionHeader") { BWidgetRegistry[type].displayLabel = "Option Header"; } - parentName = BWidgetRegistry[type].parent; - while (parentName) { + $.each(BWidget.getAncestors(type), function (i, parentName) { if (BWidgetRegistry[parentName].zones) { newZones = []; $.each(BWidgetRegistry[parentName].zones, function (i, pZone) { @@ -2541,8 +2540,7 @@ var BWidget = { $.merge(BWidgetRegistry[type].zones, newZones); } BWidgetRegistry[type] = $.extend(true, true, {}, BWidgetRegistry[parentName], BWidgetRegistry[type]); - parentName = BWidgetRegistry[parentName].parent; - } + }); } } }, @@ -3237,6 +3235,20 @@ var BWidget = { zoneName); }, + // helper function + getAncestors: function (type) { + var ancestors = [], + parents = BWidgetRegistry[type].parent; + if (!parents) + return []; + if ( typeof parents === "string") + parents = [parents]; + ancestors = $.merge(ancestors, parents); + $.each(parents, function (i, parentName) { + $.merge(ancestors, BWidget.getAncestors(parentName)); + }) + return ancestors; + }, // helper function isTypeInList: function (type, list) { // requires: list can be an array, a string, or invalid @@ -3247,11 +3259,7 @@ var BWidget = { isType = function (srcType, targetType) { if (srcType === targetType) return true; - while (srcType && (srcType = BWidgetRegistry[srcType].parent)) { - if (srcType === targetType) - return true; - } - return false; + return BWidget.getAncestors(srcType).indexOf(targetType) !== -1; }; if (list) { if (isType(type, list)) { From b1523a05e41bd85f1d1f853e6c773ea126651bb1 Mon Sep 17 00:00:00 2001 From: John Chen Date: Wed, 8 Aug 2012 16:22:12 +0800 Subject: [PATCH 18/26] [Widgets] Use multiple inheritance to implement split list widgets --- src/js/widgets.js | 198 ++-------------------------------------------- 1 file changed, 5 insertions(+), 193 deletions(-) diff --git a/src/js/widgets.js b/src/js/widgets.js index 38df6deb..c49b4964 100644 --- a/src/js/widgets.js +++ b/src/js/widgets.js @@ -1636,7 +1636,6 @@ var BWidgetRegistry = { }, ], init: function (node) { - // initial state is three TextButton var widgit; widgit = ADM.createNode("Text"); widgit.setProperty("type", "h3"); @@ -1719,7 +1718,6 @@ var BWidgetRegistry = { } ], init: function (node) { - // initial state is a ThumbnailButton var image = ADM.createNode("Image"); var text = ADM.createNode("Text"); text.setProperty("type", "h3"); @@ -1794,95 +1792,33 @@ var BWidgetRegistry = { * Represents a SplitListItem element. */ ButtonSplitListItem: { - parent: "SplitListItemBase", + parent: [ "ButtonListItem", "SplitListItemBase" ], displayLabel: "Button Split List Item", paletteImageName: "jqm_button_split_list_item.svg", allowIn: [ "ButtonSplitList" ], - template: '
                                  • %TEXT%
                                  • ', - editable: { - selector: "", - propertyName: "text" - }, - properties: { - text: BCommonProperties.text, - }, }, /** * Represents a SplitListItem element. */ IconSplitListItem: { - parent: "ButtonSplitListItem", + parent: [ "IconListItem", "ButtonSplitListItem" ], displayLabel: "Icon Split List Item", paletteImageName: "jqm_icon_split_list_item.svg", allowIn: [ "IconSplitList" ], - properties: { - text: { - defaultValue: "Icon List Item" - }, - iconsrc: { - type: "url-uploadable", - defaultValue: "src/css/images/widgets/tizen_image.svg", - htmlSelector: "img", - htmlAttribute: "src", - forceAttribute: true - }, - countbubble: { - type: "string", - displayName: "count bubble", - defaultValue: "0" - } - }, - template: function(node) { - var prop, iconsrc, countBubble, code = $('
                                  • %TEXT%
                                  • '); - prop = node.getProperty("countbubble"); - // Add the count bubble if countbubble property is not blank - if (prop.trim() != '') { - countBubble = $('') - .attr('class', 'ui-li-count') - .html(prop); - code.find('a').append(countBubble); - }; - prop = node.getProperty("iconsrc"); - // Add the count bubble if iconsrc property is not blank - if (prop.trim() != '') { - iconsrc = $('') - .attr('width','16') - .attr('class', 'ui-li-icon'); - code.find('a').append(iconsrc); - }; - return code; - } }, /** * Represents a SplitListItem element. */ TextSplitListItem: { - parent: "SplitListItemBase", + parent: [ "TextListItem", "SplitListItemBase" ], displayLabel: "Text Split List Item", paletteImageName: "jqm_text_split_list_item.svg", allowIn: [ "TextSplitList" ], - zones: [ - { - name: "default", - cardinality: "N", - locator: "a", - allow: [ "Text" ] - } - ], init: function (node) { - // initial state is three buttons - var widgit; - widgit = ADM.createNode("Text"); - widgit.setProperty("type", "h3"); - widgit.setProperty("text", "Text List Item"); - node.addChild(widgit); - widgit = ADM.createNode("Text"); - widgit.setProperty("type", "p"); - widgit.setProperty("text", "Text List Item"); - node.addChild(widgit); - node.addChild(ADM.createNode("ListButton")); + BWidgetRegistry.TextListItem.init(node); + BWidgetRegistry.SplitListItemBase.init(node); } }, @@ -1920,130 +1856,6 @@ var BWidgetRegistry = { template: '', }, - /** - * Represents a button. A Icon_Image property holds the button text. - */ - IconButton: { - parent: "ButtonBase", - displayLabel: "Icon list Button", - paletteImageName: "jqm_icon_list_button.svg", - allowIn: [ "IconListItem", "IconSplitListItem" ], - properties: { - text: { - defaultValue: "Icon List Item" - }, - iconsrc: { - type: "url-uploadable", - defaultValue: "src/css/images/widgets/tizen_image.svg", - forceAttribute: true - }, - countbubble: { - type: "string", - displayName: "count bubble", - defaultValue: "0" - } - }, - template: function(node) { - var prop, iconsrc, countBubble, code = $('%TEXT%<'); - prop = node.getProperty("countbubble"); - // Add the count bubble if countbubble property is not blank - if (prop.trim() != '') { - countBubble = $('') - .attr('class', 'ui-li-count') - .html(prop); - code.append(countBubble); - }; - prop = node.getProperty("iconsrc"); - // Add the count bubble if iconsrc property is not blank - if (prop.trim() != '') { - iconsrc = $('') - .attr('src', prop) - .attr('width','16') - .attr('class', 'ui-li-icon'); - code.append(iconsrc); - }; - return code; - } - }, - - /** - * Represents a button. A Image property holds the button text. - */ - ThumbnailButton: { - parent: "ButtonBase", - displayLabel: "Thumbnail list Button", - paletteImageName: "jqm_thumbnail_list_button.svg", - allowIn: [ "ThumbnailSplitListItem", "ThumbnailListItem" ], - properties: { - text: { - type: "string", - defaultValue: "ThumbnailSplit List Item" - }, - }, - template:'', - zones: [ - { - name: "left", - cardinality: "1", - allow: [ "Image" ] - }, - { - name: "right", - cardinality: "N", - allow: [ "Text" ] - } - ], - init: function (node) { - // initial state is three Image and Texts - var image = ADM.createNode("Image"); - var text = ADM.createNode("Text"); - text.setProperty("type", "h3"); - text.setProperty("text", "Thumbnail List Item"); - node.addChild(text); - text = ADM.createNode("Text"); - text.setProperty("type", "p"); - text.setProperty("text", "Thumbnail List Item"); - node.addChild(text); - node.addChild(image); - } - }, - - /** - * Represents a button. A Image property holds the button text. - */ - TextButton: { - parent: "ButtonBase", - displayLabel: "Text list Button", - paletteImageName: "jqm_text_list_button.svg", - allowIn: [ "TextListItem", "TextSplitListItem" ], - properties: { - text: { - type: "string", - defaultValue: "Text List Item" - }, - }, - template:'', - zones: [ - { - name: "right", - cardinality: "N", - allow: [ "Text" ] - } - ], - init: function (node) { - // initial state is three Image and Texts - var widgit; - widgit = ADM.createNode("Text"); - widgit.setProperty("type", "h3"); - widgit.setProperty("text", "Text List Item"); - node.addChild(widgit); - widgit = ADM.createNode("Text"); - widgit.setProperty("type", "p"); - widgit.setProperty("text", "Text List Item"); - node.addChild(widgit); - } - }, - /** * Represents a div element. */ From 2f66eb1f7ff0e7d8c5283fc678f214e1ccfddc7a Mon Sep 17 00:00:00 2001 From: John Chen Date: Thu, 9 Aug 2012 11:38:29 +0800 Subject: [PATCH 19/26] [Widgets] Remove unused svg files and display labels --- .../images/widgets/jqm_button_list_item.svg | 28 ------------------ .../widgets/jqm_button_split_list_item.svg | Bin 2464 -> 0 bytes src/css/images/widgets/jqm_icon_list_item.svg | Bin 2444 -> 0 bytes .../widgets/jqm_icon_split_list_item.svg | Bin 2468 -> 0 bytes src/css/images/widgets/jqm_text_list_item.svg | 28 ------------------ .../widgets/jqm_text_split_list_item.svg | Bin 2458 -> 0 bytes .../widgets/jqm_thumbnail_list_item.svg | 24 --------------- .../widgets/jqm_thumbnail_split_list_item.svg | 24 --------------- src/js/widgets.js | 18 ----------- 9 files changed, 122 deletions(-) delete mode 100644 src/css/images/widgets/jqm_button_list_item.svg delete mode 100644 src/css/images/widgets/jqm_button_split_list_item.svg delete mode 100644 src/css/images/widgets/jqm_icon_list_item.svg delete mode 100644 src/css/images/widgets/jqm_icon_split_list_item.svg delete mode 100644 src/css/images/widgets/jqm_text_list_item.svg delete mode 100644 src/css/images/widgets/jqm_text_split_list_item.svg delete mode 100644 src/css/images/widgets/jqm_thumbnail_list_item.svg delete mode 100644 src/css/images/widgets/jqm_thumbnail_split_list_item.svg diff --git a/src/css/images/widgets/jqm_button_list_item.svg b/src/css/images/widgets/jqm_button_list_item.svg deleted file mode 100644 index 097e1803..00000000 --- a/src/css/images/widgets/jqm_button_list_item.svg +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - -Button List Item - diff --git a/src/css/images/widgets/jqm_button_split_list_item.svg b/src/css/images/widgets/jqm_button_split_list_item.svg deleted file mode 100644 index 1a0b781c3df3d82607c47374831d25c468a794d1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2464 zcma);YflqF6o%ignD`%7_<$zTvaMpN^@ey$R7?9)+alQ?;r`k4%=)M*d%vwBvkGNh zAM}E!?dO5=OmBl9v)aSzKu4;F^Y8L1@vHKGi2u8szu>tE&mP{kuwEW%ET3zPmdYc~ z@^HS5-fgU;IFi@X^O6UDI!HKEud#O)^4CO{GZwSj!-DBo@w!5;y^>dxTIy)*hV1WO zS!1r{u*wD5sMS6#lA&Sn^(<&idslIW2)<*@IoS);Tou*MCH9E5L#`c{byW+rQz&hu zSE$Euq&dTy>uDWX;7+L8)E05I!NL|fY-t~@eI!r7S$=Tu2TH7ShCdB<1L|i##;1{TL!UwCs-A$&C%ij5rWDs>^topSM6omS zA=A&Pyh(0S;((lW@t}_0HR5o;t)t2KS>UZrk9I;vyJY45KQ$i{aVuy#;jOEinx{8P z;41zn%kGQIZEX>eZIy`1eLk;Sm)QL^;msF)Ddeyb&^(!2pH0@FLCs^{XQ+ki*1~3n zRcECe>N%(9g=O?i!>7-uVRIInsjtiD)+X)7?rM|u{%C@D+PM<;C3Sk7O|L+NJG~kD z$B5k|ro_F0Ob4mh`zJh&!u4}}u0h`jr}lS<9{11^tE9U@|nlw`?Q#j+< zGJJR7TcqO?)@SJBi0wmc8+nK1)Yxz1U7P{-V2pmBd1w9ws$dLws@63}#N##2=l^X) z->+ulIX2R-Xv3KKSAC|TC(fRnY2z53UUEXC&$leRT+LZVsIxoiV>0h)n0AE95&-l4BJjFb9`b;q+ z>>y;OPmc_lPC0yzEzWk|63gr=tP-BwMR$$a6YEx-vT0^o_ QQVws<)Oa?mV!J_f6tIxZ8mbRoQ z*_@u;nc2C%GpB!kH}qHo9jc>DXKJaZ6SZ}ut{!Syxk_5#ox$m<34I4{S9^hbs=jtL zkJKVEkM&45bwdr^(y~_dT<`TsYkI-$6LjzKUeku2>5W$4X55)qne|as&fYC^XBp1A zKIj#1+s^~%h28}}rnQgNzK&H7^zZU2@l^Re!v8(!uXt}EvyZn;td|Ro=7ux%27Birf1BuX#$r~xSTO%OURTJqSMq9HOC61!ko|*e zYs|G2R(a%Z)M}p=$j~78dLA^Uv#U5o1mCgdoa_f~u8L|GH};9OO|Bi6byY`rXK-5F zenve8h2{)vuBUZmK{}yoOWVZN0t?&Zu&D#I_PBWp&SGx6L0i-?NlVOholGAG4Xt4F z7%eSm#6;Q=lV(a~f@GvE zA$J$K1v)-qeTqJg*gnFxk#|H+jr|th#Tj4^hUhoVC(F-M1!KTdwXPW=9N5#FarWd)8^;)DoO3gdtJEVi#W!MD*|{Kl8D$H)ALy4+7HgDH z=Dd3vd3ui9n<-{;oXqwnPPw<#&R>8#@Xx~THI%!2376!Zd6}YAj#MpBt3kGc6<5B7 zbd7J3rK8Lbd`&(%hpEr5?y^Ph-VaZ0Li`b(mt*(zAGOm5Ujt&#c-$GDVxBrZrkD|S z7&6nNM+Qu%9684pXS=@=OPngK5}w>cca7N->oz)N)6BHS*=tO)*-JY7Pv-}o`o8}G z*h1>^ulk0Uo1EPPU3NyFF>IRSGq)f1{%W}6RtnjS3PjlqT9kF}Q&xs^DE`BU=f9l? BUa9~9 diff --git a/src/css/images/widgets/jqm_icon_split_list_item.svg b/src/css/images/widgets/jqm_icon_split_list_item.svg deleted file mode 100644 index c17666240ba5b10a1c34570057439798bceca8c3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2468 zcma);YflqF6o%ignD`%7_<$tRvaMpN^^O-36%s^aj3H18R7$~8uxR}2>hsR*(3TV> zlXhq3+|PN>+5Pjop~o8NP#tADQ%gOasI4P)^-$BwRnh{_3`$o`?suSewHK(T>T6f? za4o{~SdVm5H`LHAEo)WJ^Ldb!Y8zR(ygl?%`E zaKD4z9jv4{lGl^-k_UgMK_WIs@IRaCo>*eBLDxprLERUM(7L1`iV zjCu?T%^B8QPwU76cS6;cwu!3+7PiS@QwM16A$bbUVs5)ZThuT~OU!hgOdkggtzh#Q zEiLYhX;*Mq*Bwr~P-2}k{AqCNQ$PDLyp5Dw`V2ak^%QJAW$)~mGP<6i&pp#8irvD8 zOg|^`Cb@BmLvq%^gF1RwiNpQ2jwa)0o?VL`ZHJ6@$jXC%YCa+2X3%uXuA|$Ur8i38 zD*h+S?u)B!Z4;4gm59oHKC8Ja?EV__=8L|J!g)r#y|q^$UEiLf;6t_IH3D_s}A%qeP&H#HbM8EHRGXFePFa|tT>zX0r;Tq=i|2CrU z*R$~w8|gP{!Lb^Bdp}^s}&g&COljgiG?yv`mpJhpQHDtAV$I6<59n zca3+Exg*aHd`&(%hpEr5?y^N>?}uM)Li`b(mt*(zAGOm5Ujt&#__;GY#XNO-Ofe(u zFl44jj|`YjIed;S&UU{gmN->dB|N!@?i#Zv)@^jkrkQDtv)7npvzK)EOXmlkTHap( zwvf8~tG?moCTI6Rm!01(Mqr=4pT@K4j@6v~u=g9p-M3Q6`CBH*WmG20WzeIXYm%}x LoKNw~BcA^P0)t~= diff --git a/src/css/images/widgets/jqm_text_list_item.svg b/src/css/images/widgets/jqm_text_list_item.svg deleted file mode 100644 index 1cdb8675..00000000 --- a/src/css/images/widgets/jqm_text_list_item.svg +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - -Text List Item - diff --git a/src/css/images/widgets/jqm_text_split_list_item.svg b/src/css/images/widgets/jqm_text_split_list_item.svg deleted file mode 100644 index 30788fadd0c37e034412b28c3750c87a108b6f58..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2458 zcma);TTc^F6ouC-CjN&J9?(Qurd2Gp-VrrXF+nuOm6pepf{nj~iXiJKc zlXhnI{j&C+`SZJ>M;dBhU1d5^TYVj=qXYHyK(oqK(jwOkPERf9+i-i@4cuc5w4(*2 zmXLX*hq|t7YUqYmw5DfzuTOfX=V%{cdzb4wZRn|9>lNG#oduOSA64bqcPr?uz**M^ zz2Iv9dEh+P+YraB_V7B;q3VHtDxVU+D*p$>zYF~Z*G**hh_;3Ia$&K2ZZUc)7m?+G zzKz{&yreu*)YI#dhj=<@xKgk2cNXf`#Fi@-tJ=eZ`B#a$LalvLRFhWfSnP)Cf4j29 zT+88<$8@7r$FxX=h9TCoU@<+ri!)?!iZ|C}FK}~JR6Ez$Bi9bKc3!qs9pjzAX`}s= zehdrC8Q$Da+sJ}+Le-|W$g2$&wy0rC->}+8^BA1P+V+CAXknU_Sm`>IJ`5Jx!RH}X z+R%(?cW~6#ZJu`E#6D-l)8J`9{~X7N8aX%g8Fa4b3D|tXy{lu+_<4*y&&+@ z{hTVB^d>d-sacl@>eyW)56{~=mW-bT?%K>~CsedcRqp@O@(~%gf~8~by1J=(W}^hI z;(zk&xwzcd78%)BiL5;5^SX73-(M5ae9@P&8a4u&Cu?ikWDgqjJl1`NUbt^9d}erc zRl1>{b6OocM$a^Snm!Giv-nJNT|W0V={HVSo2vJV4dQL*PB@k{>2Wu`0ui3{W|$u% zc9Wcv^aeT|wBqa^b2SRr&+)kieVf>vd2N=!}KDU~Ubk+zK7 z9po07_=NQt<~U;e0N+O50W~%D+e8<4fFl^8-!wm2et|9+1Kz52&5`lwjOzJ+A2If; z`B=qA`i=WAX8zTmY3PZ&CuiF@$GGEMn@L=y8JR2I5u?uD3bGebwy1l7ei3D{M+s%F zySI_I=cK>6VkgJV>}cYadqeO12DlCXB;37(a)&qJvV3P=rYMyoRSVQ=kgedwov$HX z<6UIwDD#6@Q%tU5nzPHNYzf_a;a8iIe?;fS+`awB{S3g@klZtVo(yj>Z=F6{%m~{L zmFY7hL$*_noO6r2-EWCyo+_LYk=(_0jolObHoj%k&a}n(D{Qj)3pV_v^MgpO?=Jv* zNK^h*--)tG{4tXz85{-#4xk!|#&eUaC8DJ7{RZ*$y)X3qEtB*zzI&pyJCQ7pwo?4w Hh|hlkF6&|4 diff --git a/src/css/images/widgets/jqm_thumbnail_list_item.svg b/src/css/images/widgets/jqm_thumbnail_list_item.svg deleted file mode 100644 index 659e8a8b..00000000 --- a/src/css/images/widgets/jqm_thumbnail_list_item.svg +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - -Thumbnail List Item - diff --git a/src/css/images/widgets/jqm_thumbnail_split_list_item.svg b/src/css/images/widgets/jqm_thumbnail_split_list_item.svg deleted file mode 100644 index bd03745a..00000000 --- a/src/css/images/widgets/jqm_thumbnail_split_list_item.svg +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - -Thumbnail Split List Item - diff --git a/src/js/widgets.js b/src/js/widgets.js index c49b4964..a2cfe52d 100644 --- a/src/js/widgets.js +++ b/src/js/widgets.js @@ -1603,8 +1603,6 @@ var BWidgetRegistry = { */ ButtonListItem: { parent: "ListItemBase", - displayLabel: "Button List Item", - paletteImageName: "jqm_button_list_item.svg", allowIn: [ "ButtonList" ], editable: { selector: ".ui-btn-text > a", @@ -1624,8 +1622,6 @@ var BWidgetRegistry = { */ TextListItem: { parent: "ListItemBase", - displayLabel: "Text List Item", - paletteImageName: "jqm_text_list_item.svg", allowIn: [ "TextList" ], zones: [ { @@ -1653,8 +1649,6 @@ var BWidgetRegistry = { */ IconListItem: { parent: "ButtonListItem", - displayLabel: "Icon List Item", - paletteImageName: "jqm_icon_list_item.svg", allowIn: [ "IconList" ], properties: { text: { @@ -1700,8 +1694,6 @@ var BWidgetRegistry = { */ ThumbnailListItem: { parent: "ListItemBase", - displayLabel: "Thumbnail List Item", - paletteImageName: "jqm_thumbnail_list_item.svg", allowIn: [ "ThumbnailList"], zones: [ { @@ -1736,8 +1728,6 @@ var BWidgetRegistry = { */ ThumbnailSplitListItem: { parent: "SplitListItemBase", - displayLabel: "Thumbnail Split List Item", - paletteImageName: "jqm_thumbnail_split_list_item.svg", allowIn: [ "ThumbnailSplitList" ], zones: [ { @@ -1793,8 +1783,6 @@ var BWidgetRegistry = { */ ButtonSplitListItem: { parent: [ "ButtonListItem", "SplitListItemBase" ], - displayLabel: "Button Split List Item", - paletteImageName: "jqm_button_split_list_item.svg", allowIn: [ "ButtonSplitList" ], }, @@ -1803,8 +1791,6 @@ var BWidgetRegistry = { */ IconSplitListItem: { parent: [ "IconListItem", "ButtonSplitListItem" ], - displayLabel: "Icon Split List Item", - paletteImageName: "jqm_icon_split_list_item.svg", allowIn: [ "IconSplitList" ], }, @@ -1813,8 +1799,6 @@ var BWidgetRegistry = { */ TextSplitListItem: { parent: [ "TextListItem", "SplitListItemBase" ], - displayLabel: "Text Split List Item", - paletteImageName: "jqm_text_split_list_item.svg", allowIn: [ "TextSplitList" ], init: function (node) { BWidgetRegistry.TextListItem.init(node); @@ -1843,8 +1827,6 @@ var BWidgetRegistry = { */ ListButton: { parent: "ButtonBase", - displayLabel: "Extra Button", - paletteImageName: "jqm_list_button.svg", allowIn: [ "SplitListItemBase"], properties: { icon: $.extend({}, BCommonProperties.icon, { From 1aa4124a46271dbda6740848d309415f14075fd4 Mon Sep 17 00:00:00 2001 From: John Chen Date: Tue, 21 Aug 2012 17:56:28 +0800 Subject: [PATCH 20/26] [Widgets] Enable count bubble on all list types Also set the default value of count bubble to empty, i.e, no count bubble --- src/js/widgets.js | 74 ++++++++++++++++++++++++++++++----------------- 1 file changed, 48 insertions(+), 26 deletions(-) diff --git a/src/js/widgets.js b/src/js/widgets.js index a2cfe52d..34cd59bf 100644 --- a/src/js/widgets.js +++ b/src/js/widgets.js @@ -1556,11 +1556,37 @@ var BWidgetRegistry = { paletteImageName: "jqm_icon_split_list.svg", }, + /** + * Represents a base ListItem element. + */ + ListItemBase: { + parent: "Base", + properties: { + countbubble: { + type: "string", + displayName: "count bubble", + defaultValue: "" + } + }, + template: function(node) { + var prop, iconsrc, countBubble, code = $('
                                  • '); + prop = node.getProperty("countbubble"); + // Add the count bubble if countbubble property is not blank + if (prop.trim() != '') { + countBubble = $('') + .attr('class', 'ui-li-count') + .html(prop); + code.append(countBubble); + }; + return code; + } + }, + /** * Represents a generic list item element. */ SimpleListItem: { - parent: "Base", + parent: "ListItemBase", displayLabel: "List Item", paletteImageName: "jqm_list_item.svg", allowIn: [ "ListBase" ], @@ -1581,28 +1607,33 @@ var BWidgetRegistry = { htmlAttribute: "data-filtertext" } }, - template: '
                                  • %TEXT%
                                  • ' + template: function (node) { + return BWidgetRegistry.ListItemBase.template(node).append(node.getProperty('text')); + }, }, /** - * Represents a ListItem element. + * Represents a Clickable ListItem element. */ - ListItemBase: { - parent: "ButtonBase", + ClickableListItem: { + parent: [ "ListItemBase", "ButtonBase" ], defaultHtmlSelector: "a", properties: { theme: $.extend(true, {}, BCommonProperties.theme, { htmlSelector: "" }) }, - template: '
                                  • ' + template: function (node) { + var code = BWidgetRegistry.ListItemBase.template(node); + return code.append($('').append(code.find('span.ui-li-count'))); + }, }, /** * Represents a list button item element. */ ButtonListItem: { - parent: "ListItemBase", + parent: "ClickableListItem", allowIn: [ "ButtonList" ], editable: { selector: ".ui-btn-text > a", @@ -1614,14 +1645,17 @@ var BWidgetRegistry = { defaultValue: "Button List Item", } }, - template: '
                                  • %TEXT%
                                  • ', + template: function (node) { + return BWidgetRegistry.ClickableListItem.template(node) + .find('a').append(node.getProperty('text')).end(); + }, }, /** * Represents a list text item element. */ TextListItem: { - parent: "ListItemBase", + parent: "ClickableListItem", allowIn: [ "TextList" ], zones: [ { @@ -1661,24 +1695,12 @@ var BWidgetRegistry = { htmlAttribute: "src", forceAttribute: true }, - countbubble: { - type: "string", - displayName: "count bubble", - defaultValue: "0" - } }, template: function(node) { - var prop, iconsrc, countBubble, code = $('
                                  • %TEXT%
                                  • '); - prop = node.getProperty("countbubble"); - // Add the count bubble if countbubble property is not blank - if (prop.trim() != '') { - countBubble = $('') - .attr('class', 'ui-li-count') - .html(prop); - code.find('a').append(countBubble); - }; + var prop, iconsrc, + code = BWidgetRegistry.ButtonListItem.template(node); prop = node.getProperty("iconsrc"); - // Add the count bubble if iconsrc property is not blank + // Add the icon if iconsrc property is not blank if (prop.trim() != '') { iconsrc = $('') .attr('width','16') @@ -1693,7 +1715,7 @@ var BWidgetRegistry = { * Represents a ThumbnailListItem element. */ ThumbnailListItem: { - parent: "ListItemBase", + parent: "ClickableListItem", allowIn: [ "ThumbnailList"], zones: [ { @@ -1764,7 +1786,7 @@ var BWidgetRegistry = { * Represents a SplitListItem element. */ SplitListItemBase: { - parent: "ListItemBase", + parent: "ClickableListItem", zones: [ { name: "extra", From 47961cdbc7a003732f131b824ebb54e9db712560 Mon Sep 17 00:00:00 2001 From: Donna Wu Date: Tue, 21 Aug 2012 14:44:04 +0800 Subject: [PATCH 21/26] [FileIO] Support themes in root directory of sandbox when exporting --- src/js/serialize.js | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/src/js/serialize.js b/src/js/serialize.js index 64f5b2cc..2ec45820 100644 --- a/src/js/serialize.js +++ b/src/js/serialize.js @@ -425,11 +425,23 @@ $(function () { } function getDesignHeaders(design, useSandboxUrl) { - var i, props, el, designRoot, headers; + var i, props, el, designRoot, headers, toCorrectPath; designRoot = design || ADM.getDesignRoot(); headers = []; props = designRoot.getProperty('metas'); + toCorrectPath = function (header) { + var path = header.value; + // If need to use sandbox url + if (header.inSandbox) { + if (useSandboxUrl) { + path = toSandboxUrl(path); + } else { + path = path.replace(/^\//, ''); + } + } + return path; + }; for (i in props) { // Skip design only header properties if (props[i].hasOwnProperty('designOnly') && props[i].designOnly) { @@ -444,12 +456,7 @@ $(function () { if ((typeof props[i].value !== 'string') || (props[i].value.length <= 0)) { continue; } - // If need to use sandbox url - if (useSandboxUrl && props[i].inSandbox) { - el = el + '="' + toSandboxUrl(props[i].value) + '"'; - } else { - el = el + '="' + props[i].value + '"'; - } + el = el + '="' + toCorrectPath(props[i]) + '"'; if (props[i].hasOwnProperty('content')) { el = el + ' content="' + props[i].content + '"'; } @@ -470,11 +477,7 @@ $(function () { } el = ''; headers.push(el); } @@ -492,11 +495,7 @@ $(function () { } el = ''; headers.push(el); } From f5d99a5bff43cc33eba8635fc74d93321bdb3b22 Mon Sep 17 00:00:00 2001 From: Donna Wu Date: Tue, 21 Aug 2012 20:55:25 +0800 Subject: [PATCH 22/26] [General] Add inSandbox flag for uploadable widget --- src/js/projects.js | 6 +++++- src/js/serialize.js | 20 ++++++++++++-------- src/js/views/layout.js | 9 --------- src/js/views/property.js | 14 +++++++------- src/js/widgets.js | 12 +++++++++--- 5 files changed, 33 insertions(+), 28 deletions(-) diff --git a/src/js/projects.js b/src/js/projects.js index fbb8a852..841f8f55 100644 --- a/src/js/projects.js +++ b/src/js/projects.js @@ -27,7 +27,9 @@ $(function () { // Filter to find sandbox resources relativeFilter:{ type: "url-uploadable", - value: /^(?!(https?|ftp):\/+).+/i + value: function (valueObject) { + return valueObject.inSandbox; + } }, // Object to save refernce count for sandbox resource resourceRef: {}, @@ -956,6 +958,7 @@ $(function () { * @return {None} */ pmUtils.addRefCount = function (refPath) { + refPath = refPath.value || refPath; if (!pmUtils.resourceRef[refPath]) { pmUtils.resourceRef[refPath] = 1; } else { @@ -972,6 +975,7 @@ $(function () { */ pmUtils.reduceRefCount = function (refPath) { var projectDir = pmUtils.ProjectDir + "/" + pmUtils.getActive() + "/"; + refPath = refPath.value || refPath; if (pmUtils.resourceRef.hasOwnProperty(refPath)) { pmUtils.resourceRef[refPath]--; // Delete the resource if the reference count is 0 diff --git a/src/js/serialize.js b/src/js/serialize.js index 2ec45820..cba181d9 100644 --- a/src/js/serialize.js +++ b/src/js/serialize.js @@ -658,7 +658,7 @@ $(function () { for (p in matched) { files.push({ "src": toSandboxUrl(matched[p]), - "dst": matched[p] + "dst": matched[p].value ? matched[p].value : matched[p] }); } }); @@ -729,19 +729,23 @@ $(function () { } function toSandboxUrl(path, pid) { - var projectDir, fullPath; + var projectDir, pathStr; pid = pid || $.rib.pmUtils.getActive(); projectDir = $.rib.pmUtils.getProjectDir(pid); - if (typeof path !== "string") { - console.error("Invalid path in toSandboxUrl: " + path); + if ((path instanceof Object) && path.inSandbox) { + pathStr = path.value; + } else { + pathStr = path; + } + if (typeof pathStr !== "string") { + console.error("Invalid path in toSandboxUrl: " + pathStr); return null; } - fullPath = path; // If the first char is '/', then it will be the absolute path in sandbox - if (path[0] !== '/' && projectDir) { - fullPath = projectDir + path; + if (pathStr[0] !== '/' && projectDir) { + pathStr = projectDir + pathStr; } - return $.rib.fsUtils.pathToUrl(fullPath); + return $.rib.fsUtils.pathToUrl(pathStr); } function indexOfArray(array, value) { diff --git a/src/js/views/layout.js b/src/js/views/layout.js index e925c36c..98fa2f0f 100644 --- a/src/js/views/layout.js +++ b/src/js/views/layout.js @@ -428,15 +428,6 @@ // these lines. $(domNode).removeAttr('disabled'); $(domNode).children().removeAttr('disabled'); - - // Set default src for empty image to make them show up - // TODO: This case may need to improve, such as we can show a box - // with "empty image" message to notice the user - if ((admNode.getType() === "Image") && (!admNode.getProperty('src'))) { - if ($(domNode).is('img')) { - $(domNode).attr('src', "src/css/images/widgets/tizen_image.svg"); - } - } } }); })(jQuery); diff --git a/src/js/views/property.js b/src/js/views/property.js index 3cbbf9de..e588bcb4 100644 --- a/src/js/views/property.js +++ b/src/js/views/property.js @@ -169,18 +169,18 @@ .addClass('title labelInput') .appendTo(value); //set default value - value.find('#' + valueId).val(valueVal); + value.find('#' + valueId).val(valueVal.value); $('') .addClass('buttonStyle') - .click(function (e) { - var target, saveDir; - target = $(this).prev("input:text"); - saveDir = $.rib.pmUtils.ProjectDir + "/" + $.rib.pmUtils.getActive() + "/images/"; + .click({node:node, property:p}, function (e) { + var saveDir = $.rib.pmUtils.getProjectDir() + "images/"; $.rib.fsUtils.upload("image", $(this).parent(), function(file) { // Write uploaded file to sandbox $.rib.fsUtils.write(saveDir + file.name, file, function (newFile) { - target.val("images/" + newFile.name); - target.trigger('change'); + ADM.setProperty(e.data.node, e.data.property, { + inSandbox: true, + value: "images/" + newFile.name + }); }); }); }).appendTo(value); diff --git a/src/js/widgets.js b/src/js/widgets.js index 34cd59bf..761fd52f 100644 --- a/src/js/widgets.js +++ b/src/js/widgets.js @@ -314,10 +314,11 @@ var BWidgetRegistry = { properties: { background: { type: "url-uploadable", - defaultValue: "", + defaultValue: {}, htmlAttribute: "style", htmlValueMap: function (propValue) { - return "background-image: url('" + propValue + "'); " + + return "background-image: url('" + + propValue + "'); " + "background-attachment: fixed; " + "background-repeat: no-repeat; " + "background-size: 100% 100%;"; @@ -773,7 +774,10 @@ var BWidgetRegistry = { properties: { src: { type: "url-uploadable", - defaultValue: "", + defaultValue: { + value: "src/css/images/widgets/tizen_image.svg", + inSandbox: false + }, htmlAttribute: "src", forceAttribute: true }, @@ -1700,6 +1704,7 @@ var BWidgetRegistry = { var prop, iconsrc, code = BWidgetRegistry.ButtonListItem.template(node); prop = node.getProperty("iconsrc"); + prop = prop.value || prop; // Add the icon if iconsrc property is not blank if (prop.trim() != '') { iconsrc = $('') @@ -2705,6 +2710,7 @@ var BWidget = { getPropertySerializableValue: function (widgetType, property, value) { var mapped, valueMap; valueMap = BWidget.getPropertyValueMap(widgetType, property); + value = (value && value.value) || value; if (typeof valueMap === "function") { mapped = valueMap(value); } else if (typeof valueMap === "object") { From 5ed3a223bf3234a506ac4dc1fa047ffa7929356a Mon Sep 17 00:00:00 2001 From: John Chen Date: Wed, 22 Aug 2012 14:56:54 +0800 Subject: [PATCH 23/26] [Layout View] Revert css changes in 8ee0558e Sorting is still OK without this change and it causes bad appearance of ButtonGroup and ThumbnailSplitList --- src/css/composer.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/css/composer.css b/src/css/composer.css index 5663474c..40b1d136 100644 --- a/src/css/composer.css +++ b/src/css/composer.css @@ -48,7 +48,7 @@ /*************************/ /* Class specific tweaks */ /*************************/ -.nrc-sortable-container.ui-content .adm-node { +.nrc-sortable-container.ui-content > * { margin-top: 10px; margin-bottom: 10px; } From 5b82f2faf6fb1611438438420ba250f16483abe0 Mon Sep 17 00:00:00 2001 From: John Chen Date: Fri, 24 Aug 2012 17:16:24 +0800 Subject: [PATCH 24/26] [ADM] Fix moveNode index caculating problem --- src/js/adm.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/js/adm.js b/src/js/adm.js index 9812fb39..6ae9cb81 100644 --- a/src/js/adm.js +++ b/src/js/adm.js @@ -1845,6 +1845,9 @@ ADMNode.prototype.moveNode = function (newParent, zoneName, zoneIndex, dryrun) { oldZone = this._zone; oldIndex = this.getZoneIndex(); removed = oldParent.removeChild(this, dryrun); + if (oldParent === newParent && oldZone === zoneName + && oldIndex < zoneIndex) + zoneIndex --; if (removed) { if (removed != this) { From 02bc28e56ea24fc3c1459699c5635f3923e50ea0 Mon Sep 17 00:00:00 2001 From: John Chen Date: Fri, 24 Aug 2012 14:25:19 +0800 Subject: [PATCH 25/26] [ADM] Use moveNode to insert child if old parent is not null --- src/js/adm.js | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/src/js/adm.js b/src/js/adm.js index 6ae9cb81..20e81603 100644 --- a/src/js/adm.js +++ b/src/js/adm.js @@ -518,7 +518,7 @@ ADM.endTransaction = function () { * @return {ADMNode} The child object, on success; null, on failure. */ ADM.addChild = function (parentRef, childRef, dryrun) { - var parent, child; + var parent, child, oldParent, oldZone, oldZoneIndex; parent = ADM.toNode(parentRef); if (!parent) { @@ -538,6 +538,11 @@ ADM.addChild = function (parentRef, childRef, dryrun) { return null; } + oldParent = child.getParent(); + if (oldParent) { + oldZone = child.getZone(); + oldZoneIndex = child.getZoneIndex(); + } if (parent.addChild(child, dryrun)) { if (dryrun) { return true; @@ -547,7 +552,10 @@ ADM.addChild = function (parentRef, childRef, dryrun) { ADM.transaction({ type: "add", parent: child.getParent(), - child: child + child: child, + oldParent: oldParent, + oldZone: oldZone, + oldZoneIndex: oldZoneIndex }); return child; } @@ -634,7 +642,7 @@ ADM.addChildRecursive = function (parentRef, childRef, dryrun) { * @private */ ADM.insertChildRelative = function (siblingRef, childRef, offset, dryrun) { - var sibling, child; + var sibling, child, oldParent, oldZone, oldZoneIndex; sibling = ADM.toNode(siblingRef); if (!sibling) { @@ -655,6 +663,11 @@ ADM.insertChildRelative = function (siblingRef, childRef, offset, dryrun) { childRef); } + oldParent = child.getParent(); + if (oldParent) { + oldZone = child.getZone(); + oldZoneIndex = child.getZoneIndex(); + } if (sibling.insertChildRelative(child, offset, dryrun)) { if (dryrun) { return true; @@ -663,7 +676,10 @@ ADM.insertChildRelative = function (siblingRef, childRef, offset, dryrun) { type: "insertRelative", sibling: sibling, child: child, - offset: offset + offset: offset, + oldParent: oldParent, + oldZone: oldZone, + oldZoneIndex: oldZoneIndex }); return child; } @@ -922,6 +938,9 @@ ADM.undo = function () { if (obj.type === "add") { ADM.ensurePageInactive(obj.child); obj.parent.removeChild(obj.child); + if (obj.oldParent) { + obj.oldParent.addChildToZone(obj.child, obj.oldZone, obj.oldZoneIndex); + } } else if (obj.type === "remove") { obj.parent.insertChildInZone(obj.child, obj.zone, obj.zoneIndex); @@ -933,6 +952,9 @@ ADM.undo = function () { } else if (obj.type === "insertRelative") { obj.sibling.getParent().removeChild(obj.child); + if (obj.oldParent) { + obj.oldParent.addChildToZone(obj.child, obj.oldZone, obj.oldZoneIndex); + } } else if (obj.type === "propertyChange") { // TODO: this could require deeper copy of complex properties @@ -1777,7 +1799,7 @@ ADMNode.prototype.insertChildInZone = function (child, zoneName, index, } } - var zone = this._zones[zoneName]; + var zone = this._zones[zoneName], oldParent, oldZone, oldZoneIndex; if (!zone) { console.error("Error: zone not found in insertChildInZone: " + zoneName); @@ -1788,6 +1810,9 @@ ADMNode.prototype.insertChildInZone = function (child, zoneName, index, return false; } if (child instanceof ADMNode) { + oldParent = child.getParent(); + if (oldParent) + return child.moveNode(this, zoneName, index, dryrun); if (!dryrun) { zone.splice(index, 0, child); From d948030e89353d4bdcb26e824150b413eeb4fe94 Mon Sep 17 00:00:00 2001 From: John Chen Date: Fri, 24 Aug 2012 14:29:10 +0800 Subject: [PATCH 26/26] [Layout View] Use a new algorithm for sorting Previous algorithm only supports one zone containers or Headers, and it works hard to determine the position for insertion. The new algorithm firstly tries to insert to the zone of the nearest sibling using enhenced insertChildAfter/Before, if fails, uses addChild to automatically find a zone to insert. --- src/js/composer.js | 153 +++++++++------------------------------------ 1 file changed, 30 insertions(+), 123 deletions(-) diff --git a/src/js/composer.js b/src/js/composer.js index 1719ac6a..f86594cc 100644 --- a/src/js/composer.js +++ b/src/js/composer.js @@ -279,58 +279,6 @@ $(function() { } }; - var addNewNodeOnDrop = function (domParent, domChildren, adm, pid, - nodeRef, role, domNode) { - var newNode, domSibling, sid, admChildren, domIndex, debug; - - debug = (window.top.$.rib && window.top.$.rib.debug()); - domIndex = domChildren.index(domNode); - - // Append first(only)/last child to this container - if (domIndex >= domChildren.length-1 || role === 'page') { - if (adm.addChild(pid, nodeRef, true)) { - newNode = adm.addChild(pid, nodeRef); - debug && console.log('Appended node',role); - newNode && adm.setSelected(newNode); - } else { - console.warn('Append child failed:',role); - } - } else if (domIndex > 0) { - // Insert nth child into this container - domSibling = $(domNode, domParent).prev('.adm-node'); - sid = domSibling.attr('data-uid'); - if (adm.insertChildAfter(sid, nodeRef, true)) { - newNode = adm.insertChildAfter(sid, nodeRef); - debug && console.log('Inserted nth node',role); - newNode && adm.setSelected(newNode); - } else { - console.warn('Insert nth child failed:',role); - } - } else { - // Add 1st child into an empty container - if (domChildren.length-1 <= 0) { - if (adm.addChild(pid, nodeRef, true)) { - newNode = adm.addChild(pid, nodeRef); - debug && console.log('Added 1st node',role); - newNode && adm.setSelected(newNode); - } else { - console.warn('Add 1st child failed:',role); - } - } else { - // Insert 1st child into non-empty container - admChildren = adm.toNode(pid).getChildren(); - sid = admChildren.length && admChildren[0].getUid(); - if (adm.insertChildBefore(sid, nodeRef, true)) { - newNode = adm.insertChildBefore(sid, nodeRef); - debug && console.log('Inserted 1st node', role); - newNode && adm.setSelected(newNode); - } else { - console.warn('Insert 1st child failed:', role); - } - } - } - }; - window.top.$.rib = window.top.$.rib || {}; window.top.$.rib.dndfilter = dndfilter; @@ -635,16 +583,14 @@ $(function() { }, stop: function(event, ui){ trackOffsets('stop: ',ui,$(this).data('sortable')); - var type, isDrop, + var isDrop, pid = $(this).attr('data-uid'), - node = null, adm = window.parent.ADM, - bw = window.parent.BWidget, root = adm.getDesignRoot(), - node, zones, newParent, newZone, - rdx, idx, cid, pid, sid, + nodeRef, newParent, + cid, pid, sibling, children, parent, - role, card; + role, prevItem = ui.item, nextItem = ui.item; role = $(this).attr('data-role') || ''; @@ -695,87 +641,48 @@ $(function() { ui.item.remove(); return false; } - - // Drop from palette: add a node if (isDrop) { if (ui.item.data('adm-node')) { - type = ui.item.data('adm-node').type; + nodeRef = ui.item.data('adm-node').type; } - if (!type) { + if (!nodeRef) { console.warn('Drop failed: Missing node type'); ui.item.remove(); return false; } - - children = $($(this).sortable('option', 'items'), this) - .add(ui.item); - addNewNodeOnDrop(this, children, adm, pid, type, - role, ui.item); - ui.item.remove(); - return; - - // Sorted from layoutView: move a node - } else { - children = ui.item.parent().children('.adm-node') - .add(ui.item); - idx = children.index(ui.item); + } + else { cid = ui.item.attr('data-uid'); // closest() will select current element if it matches // the selector, so we start with its parent. + nodeRef = cid && root.findNodeByUid(cid); + if (event && event.ctrlKey) { + nodeRef = adm.copySubtree(nodeRef); + } + } + + while (prevItem[0] || nextItem[0]) { + prevItem = prevItem.prev('.adm-node'); + if (prevItem[0] && adm.insertChildAfter + (prevItem.attr('data-uid'), nodeRef)) + break; + nextItem = nextItem.next('.adm-node'); + if (nextItem[0] && adm.insertChildBefore + (nextItem.attr('data-uid'), nodeRef)) + break; + } + if (!prevItem[0] && !nextItem[0]) { pid = ui.item.parent() .closest('.adm-node.ui-sortable,'+ '.orig-adm-node.ui-sortable') .attr('data-uid'); - node = cid && root.findNodeByUid(cid); - if (event && event.ctrlKey) { - node = adm.copySubtree(node); // Clone it - addNewNodeOnDrop(this, children, adm, pid, node, - role, ui.item); - } else { - newParent = pid && root.findNodeByUid(pid); - zones = newParent && bw.getZones(newParent.getType()); - card = newParent && zones && - bw.getZoneCardinality(newParent.getType(), - zones[0]); - - // Notify the ADM that element has been moved - if ((zones && zones.length===1 && card !== '1')) { - if (!node || - !adm.moveNode(node, newParent, zones[0], - idx)) { - console.warn('Move node failed'); - ui.item.remove(); - return false; - } else { - debug && console.log('Move node worked'); - if (node) adm.setSelected(node.getUid()); - } - } else if (node && newParent && - newParent.getType() === 'Header') { - for (var z=0; z < zones.length; z++) { - if (adm.moveNode(node, newParent, zones[z], - 0, true)) { - newZone = zones[z]; - break; - } - } - if (newZone) { - adm.moveNode(node, newParent, newZone, 0); - debug && console.log('Move node worked'); - if (node) adm.setSelected(node.getUid()); - } else { - console.warn('Move node failed'); - ui.item.remove(); - return false; - } - } else { - console.warn('Move node failed: invalid zone'); - ui.item.remove(); - return false; - } - } + newParent = pid && root.findNodeByUid(pid); + if (nodeRef = adm.addChild(newParent, nodeRef)) + return false; } + if (nodeRef) + adm.setSelected(nodeRef); } }) .bind('mousedown.composer', function(event) {