3 <title>The source code</title>
\r
4 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
\r
5 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
\r
7 <body onload="prettyPrint();">
\r
8 <pre class="prettyprint lang-js">Imgorg.ImageThumbPanel = Ext.extend(Ext.Panel, {
12 initComponent: function() {
13 this.tfId = 'tag-filter-'+Ext.id();
16 var p = Ext.state.Manager.getProvider();
18 sliderValue = Ext.num(p.get('sliderValue'), 0);
29 xtype: 'img-tagmulticombo',
32 select: function(combo, record, idx) {
33 var vals = combo.getValue();
37 clearall: function(combo) {
44 itemId: 'size-slider',
46 style: 'margin-right:20px;',
48 plugins: new Ext.ux.SliderTip({
49 getText: function(slider){
50 return String.format('<b>{0}%</b>', 100+slider.getValue()*3);
54 change: this.onChange,
59 Imgorg.ImageThumbPanel.superclass.initComponent.call(this);
60 this.on('activate', this.onActivate, this);
63 afterRender: function() {
64 Imgorg.ImageThumbPanel.superclass.afterRender.call(this);
65 this.view = this.getComponent('imgorg-dv');
67 this.dragZone = new ImageDragZone(this.view, {
69 ddGroup: 'organizerDD'
74 onActivate: function() {
76 var p = Ext.state.Manager.getProvider();
78 sliderValue = Ext.num(p.get('sliderValue'), 0);
79 var slider = this.getBottomToolbar().getComponent('size-slider');
80 slider.setValue(sliderValue);
81 this.onChange(slider);
85 onChange: function(slider, e) {
86 var p = Ext.state.Manager.getProvider();
88 p.set('sliderValue', slider.getValue());
90 Ext.util.CSS.updateRule('.images-view .thumb img','height',this.minWidth+slider.getValue()*3);
93 tagFilter: function(vals) {
94 if (this.view.store.lastOptions.params) {
95 var album = this.view.store.lastOptions.params.album;
98 this.view.store.load({
106 clearFilter: function() {
107 var album = this.view.store.lastOptions.params.album;
108 this.view.store.load({
113 Ext.getCmp(this.tfId).reset();
116 albumFilter: function(album) {
117 this.getComponent('imgorg-dv').store.load({
125 this.view.store.reload();
128 Ext.reg('img-thumbpanel', Imgorg.ImageThumbPanel);
131 ImageDragZone = function(view, config){
133 ImageDragZone.superclass.constructor.call(this, view.getEl(), config);
135 Ext.extend(ImageDragZone, Ext.dd.DragZone, {
136 // We don't want to register our image elements, so let's
137 // override the default registry lookup to fetch the image
138 // from the event instead
139 getDragData : function(e){
140 var target = e.getTarget('.thumb-wrap');
142 var view = this.view;
143 if(!view.isSelected(target)){
146 var selNodes = view.getSelectedNodes();
150 if(selNodes.length == 1){
151 dragData.ddel = target;
152 dragData.single = true;
154 var div = document.createElement('div'); // create the multi element drag "ghost"
155 div.className = 'multi-proxy';
156 for(var i = 0, len = selNodes.length; i < len; i++){
157 div.appendChild(selNodes[i].firstChild.firstChild.cloneNode(true)); // image nodes only
159 div.appendChild(document.createElement('br'));
162 var count = document.createElement('div'); // selected image count
163 count.innerHTML = i + ' images selected';
164 div.appendChild(count);
167 dragData.multi = true;
174 // this method is called by the TreeDropZone after a node drop
175 // to get the new tree node (there are also other way, but this is easiest)
176 getTreeNode : function(){
178 var nodeData = this.view.getRecords(this.dragData.nodes);
179 for(var i = 0, len = nodeData.length; i < len; i++){
180 var data = nodeData[i].data;
181 treeNodes.push(new Ext.tree.TreeNode({
183 icon: '../view/'+data.url,
192 // the default action is to "highlight" after a bad drop
193 // but since an image can't be highlighted, let's frame it
194 afterRepair:function(){
195 for(var i = 0, len = this.dragData.nodes.length; i < len; i++){
196 Ext.fly(this.dragData.nodes[i]).frame('#8db2e3', 1);
198 this.dragging = false;
201 // override the default repairXY with one offset for the margins and padding
202 getRepairXY : function(e){
203 if(!this.dragData.multi){
204 var xy = Ext.Element.fly(this.dragData.ddel).getXY();